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

Updated Examples (markdown)

Matthew Bennett
2020-10-17 17:34:55 +02:00
parent 04a4f6ee74
commit 78f5051503

@@ -120,6 +120,34 @@ fo() {
}
```
```sh
# select files with fzf and send to command.
# Put non-GUI processes in the foreground
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
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
fg %%
fi
}
```
```sh
# vf - fuzzy open with vim from anywhere
# ex: vf word1 word2 ... (even part of a file name)