m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 00:53:42 -05:00

Updated Examples (markdown)

Matthew Bennett
2020-10-17 17:45:18 +02:00
parent 3c111684d3
commit c376f1778b

@@ -121,35 +121,36 @@ fo() {
``` ```
```sh ```sh
# select files with fzf and send to command. # select files with fzf and send to command.
# Put non-GUI processes in the foreground # Put non-GUI processes in the foreground
# Usage: # Usage:
# f cd (hit enter, choose path) # f cd (hit enter, choose path)
# f cat (hit enter, choose files)
# f vim (hit enter, choose files) # f vim (hit enter, choose files)
# f vlc (hit enter, choose files) # f vlc (hit enter, choose files)
f() { f() {
# store the files from fzf # store the files from fzf
IFS=$'\n' files=($(fzf --query="$2" --multi)) IFS=$'\n' files=($(fzf --query="$2" --multi))
# if no files passed (e.g. if Esc pressed), return to terminal # if no files passed (e.g. if Esc pressed), return to terminal
if [ -z "${files}" ]; then if [ -z "${files}" ]; then
return 1 return 1
fi fi
# send the files to a program # 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 if ! [[ $1 =~ ^(cd)$ ]]; then
$1 "${files[@]}" & $1 "${files[@]}" &
else else
$1 "${files[@]}" $1 "${files[@]}"
fi fi
# if the program is not on the list of GUIs (e.g. vim, cat, etc.) bring it # 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 # to foreground so we can see the output. Also put cd on this list.
if ! [[ $1 =~ ^(zathura|vlc)$ ]]; then if ! [[ $1 =~ ^(cd|zathura|vlc)$ ]]; then
fg %% fg %%
fi fi
} }
``` ```
```sh ```sh