Skip to content

Instantly share code, notes, and snippets.

@swdunlop
Created November 15, 2018 22:25
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 swdunlop/b3345e67f5ca75f8560cf498d1820bf2 to your computer and use it in GitHub Desktop.
Save swdunlop/b3345e67f5ca75f8560cf498d1820bf2 to your computer and use it in GitHub Desktop.
A few Fish functions for browsing files using FZF, Highlight and RipGrep
#!/usr/bin/env fish
function fzf-files
fzf \
--header 'Enter to open in Sublime, ctrl-y to copy path' \
--bind 'enter:execute-silent:subl {}' \
--bind 'ctrl-y:execute-silent:echo {} | pbcopy' \
--preview 'highlight -O xterm256 -s darkbone -l {} 2>/dev/null ||
cat {}'
end
function fzf-find
if count $argv >/dev/null
find $argv -type f | fzf-files
else
find . -type f | fzf-files
end
end
function fzf-rg
rg -l $argv | fzf-files
end
@swdunlop
Copy link
Author

I love FZF, but adding key bindings and hacking around read in Fish seems.. Suboptimal. It's easier just to add a few functions, IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment