From 8f641a314932bd897bd1e83baaf856727ec6e515 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 25 Apr 2017 17:18:19 -0400 Subject: [PATCH] shell/fzf: improve fzf-apps + scratch terminal integration + refactor --- shell/fzf/bin/fzf-apps | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/shell/fzf/bin/fzf-apps b/shell/fzf/bin/fzf-apps index 454d7217..cabedf0e 100755 --- a/shell/fzf/bin/fzf-apps +++ b/shell/fzf/bin/fzf-apps @@ -12,17 +12,23 @@ case $OSTYPE in linux*) cmd=$(echo -n "$PATH" | xargs -d: -I{} -r -- find -L {} -maxdepth 1 -mindepth 1 -type f -executable -printf '%P\n' 2>/dev/null | sort -u | gui-fzf) if [[ $cmd ]]; then - if ! which lnch >/dev/null; then - notify-send 'lnch is not installed' 'run "go get github.com/oem/lnch"' - exit 1 - fi - - # This disowns the subprocess from the parent shell (i.e. if - # that shell gets closed, the subprocess will survive). if [[ $cmd == fzf-* ]]; then $cmd else + if ! which lnch >/dev/null; then + notify-send 'lnch is not installed' 'run "go get github.com/oem/lnch"' + exit 1 + fi + + # This disowns the subprocess from the parent shell (i.e. if + # that shell gets closed, the subprocess will survive). lnch "$cmd" + + # OPTIONAL: requires bin/tmux + if command -v 'tmux-session-name' >/dev/null; then + # If this was used from a scratch tmux terminal, close it + [[ "$(tmux-session-name)" == scratch ]] && tmux kill-session -t scratch + fi fi fi ;;