1234567891011121314151617181920212223242526272829 |
- export FZF_DEFAULT_OPTS="--layout=reverse --bind=ctrl-z:ignore,ctrl-a:select-all"
- fzf_history() {
- local selected=$(sed 's/^[^;]*;//' $HISTFILE | \
- FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS --tiebreak=index --tac --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf)
- local ret=$?
- if [ -n "$selected" ]; then
- BUFFER="$selected"
- fi
- zle reset-prompt
- return $ret
- }
- fzf_cd() {
- local start=${1:-.}
- local selected=$(find "$start" -type d -printf "%P\n" | \
- FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf)
- local ret=$?
- if [ $ret -ne 0 ]; then
- return $ret
- fi
- if [ -n "$selected" ]; then
- cd "$start/$selected"
- fi
- }
- zle -N fzf_history
|