From c376f1778b7d02f4b582df37c37dfdff5e195ebe Mon Sep 17 00:00:00 2001 From: Matthew Bennett Date: Sat, 17 Oct 2020 17:45:18 +0200 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Examples.md b/Examples.md index b0e61d1..c3f80ea 100644 --- a/Examples.md +++ b/Examples.md @@ -121,35 +121,36 @@ fo() { ``` ```sh -# select files with fzf and send to command. -# Put non-GUI processes in the foreground +# select files with fzf and send to command. +# Put non-GUI processes in the foreground # Usage: # f cd (hit enter, choose path) +# f cat (hit enter, choose files) # f vim (hit enter, choose files) -# f vlc (hit enter, choose files) +# f vlc (hit enter, choose files) f() { # store the files from fzf IFS=$'\n' files=($(fzf --query="$2" --multi)) - + # if no files passed (e.g. if Esc pressed), return to terminal if [ -z "${files}" ]; then return 1 fi # send the files to a program - # some programs should not be run as background + # some programs should not be run as background if ! [[ $1 =~ ^(cd)$ ]]; then $1 "${files[@]}" & else $1 "${files[@]}" fi - + # if the program is not on the list of GUIs (e.g. vim, cat, etc.) bring it - # to foreground so we can see the output - if ! [[ $1 =~ ^(zathura|vlc)$ ]]; then + # to foreground so we can see the output. Also put cd on this list. + if ! [[ $1 =~ ^(cd|zathura|vlc)$ ]]; then fg %% fi -} +} ``` ```sh