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