fzf.zsh (729B)
1 # A collection of useful fzf wrapper functions 2 3 # visual config 4 export FZF_DEFAULT_OPTS='--height 40% --exact' 5 export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'" 6 export FZF_CTRL_R_OPTS='--sort --exact' 7 8 # repeat history 9 fh() { 10 print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) \ 11 | fzf +s --tac \ 12 | sed 's/ *[0-9]* *//') 13 } 14 15 # copy history 16 fhc() { 17 echo -n $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) \ 18 | fzf +s --tac | sed 's/ *[0-9]* *//') \ 19 | pbcopy 20 } 21 22 # kill a process 23 fkill() { 24 local pid 25 pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}') 26 27 if [ "x$pid" != "x" ] 28 then 29 echo $pid | xargs kill -${1:-9} 30 fi 31 }