-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Examples (fish)
Pierre Neidhardt edited this page Dec 13, 2016
·
27 revisions
function fzf-bcd-widget -d 'cd backwards'
pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | eval (__fzfcmd) +m --select-1 --exit-0 $FZF_BCD_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end
function fzf-cdhist-widget -d 'cd to one of the previously visited location'
## Clear non-existent folders from cdhist.
set -l buf
for i in (seq 1 (count $dirprev))
set -l dir $dirprev[$i]
if test -d $dir
set buf $buf $dir
end
end
set dirprev $buf
string join \n $dirprev | tac | sed 1d | eval (__fzfcmd) +m $FZF_CDHIST_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end
function fco -d "Fuzzy-find and checkout a branch"
git branch --all | grep -v HEAD | string trim | fzf | xargs git checkout
end
function fcoc -d "Fuzzy-find and checkout a commit"
git log --pretty=oneline --abbrev-commit --reverse | fzf +s | xargs git checkout
end
function fssh -d "Fuzzy-find ssh host and ssh into it"
ag '^host [^*]' ~/.ssh/config | cut -d ' ' -f 2 | fzf | xargs -o ssh
end
function fs -d "Switch tmux session"
tmux list-sessions -F "#{session_name}" | fzf | xargs tmux switch-client -t
end
function fpass -d "Fuzzy-find a Lastpass entry and copy the password"
if not lpass status -q
lpass login $EMAIL
end
if not lpass status -q
exit
end
lpass ls | fzf | string replace -r -a '.+\[id: (\d+)\]' '$1' | xargs lpass show -c --password
end