]>
git.rmz.io Git - dotfiles.git/blob - zsh/lib/fzf.zsh
1 if ! hash fzf
2>/dev
/null
; then
2 echo '`fzf` is not installed.'
8 if [[ -f /usr
/share
/zsh
/site
-functions/_fzf
]]; then
9 source /usr
/share
/zsh
/site
-functions/_fzf
15 # CTRL-T - Paste the selected file path(s) into the command line
17 command find -L . \
( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \
) -prune \
20 -o -type l
-print 2> /dev
/null
| sed 1d
| cut
-b3- | fzf
-m | while read item
; do
26 if [[ $
- =~ i
]]; then
28 if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then
31 height
=${FZF_TMUX_HEIGHT:-40%}
32 if [[ $height =~
%$
]]; then
33 height
="-p ${height%\%}"
37 tmux
split-window $height "cd $(printf %q "$PWD");zsh -c 'tmux send-keys -t $TMUX_PANE \"\$(__fsel)\"'"
41 LBUFFER
="${LBUFFER}$(__fsel)"
45 zle
-N fzf
-file-widget
46 bindkey
'^T' fzf
-file-widget
48 # ALT-C - cd into the selected directory
50 cd "${$(command find -L . -xdev \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
51 -o -type d -print 2> /dev/null | sed 1d | cut -b3- | fzf +m):-.}"
55 bindkey
'\ec' fzf
-cd-widget
57 # CTRL-R - Paste the selected command from history into the command line
58 fzf
-history-widget() {
60 if selected
=$(fc -l 1 | fzf -x +s --tac +m -n2..,.. --toggle-sort=ctrl-r -q "$LBUFFER"); then
61 num
=$(echo "$selected" | head -1 | awk '{print $1}' | sed 's/[^0-9]//g')
67 zle
-N fzf
-history-widget
68 bindkey
'^R' fzf
-history-widget
70 # ALT-I - Paste the selected entry from locate output into the command line
73 if selected
=$(locate / | fzf -q "$LBUFFER"); then
78 zle
-N fzf
-locate-widget
79 bindkey
'\ei' fzf
-locate-widget