Skip to content

Instantly share code, notes, and snippets.

@bkono
Last active May 26, 2022 22:17
Show Gist options
  • Save bkono/7c7a5c1f30a54d80c751d0782be82f6e to your computer and use it in GitHub Desktop.
Save bkono/7c7a5c1f30a54d80c751d0782be82f6e to your computer and use it in GitHub Desktop.
Some useful FZF fish funcs
function f -d "Fuzzy-find and open a file in current directory"
set file (fzf --height 40% --info inline --border --reverse --preview 'bat {}')
if test -n "$file"
nvim $file
end
end
function fb -d "Fuzzy-find and checkout a branch"
git rev-parse HEAD > /dev/null 2>&1 || return
git branch --all --sort=-committerdate | grep -v HEAD | string trim | fzf -d 15 --reverse --preview='git show --color=always --stat --patch {1}' | read -l result
if test -n "$result"
if string match "remotes/*" "$result"
git checkout -t "$result"
else
git checkout "$result"
end
end
end
function fl -d "Fuzzy-search through git log"
_fzf_search_git_log
end
function fs -d "Switch tmux session"
tmux list-sessions -F "#{session_name}" | fzf | read -l result; and tmux switch-client -t "$result"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment