Skip to content

Instantly share code, notes, and snippets.

@atmoz
Created March 9, 2020 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atmoz/3dde4786371df4473161002dcc682dd3 to your computer and use it in GitHub Desktop.
Save atmoz/3dde4786371df4473161002dcc682dd3 to your computer and use it in GitHub Desktop.
Recursive content search with FZF in LF
map ` ${{
fz=$(grep --line-buffered --color=never -r -n "" * \
| fzf -d: -e -m -n3.. \
--preview 'head -$LINES {1} | grep --color=always -i -e "^" -e {q}' --preview-window=noborder \
--layout=reverse \
| cut -d: -f1 | sort | uniq)
if [ -n "$fz" ]; then
pwd=$PWD
for f in $fz; do
d=$(dirname $f)
n=$(basename $f)
lf -remote "send $id cd $d"
lf -remote "send $id glob-select $n"
done
lf -remote "send $id cd $pwd"
lf -remote "send $id select ${fz[0]}"
fi
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment