1
0

fzf.zsh 794 B

1234567891011121314151617181920212223242526272829
  1. export FZF_DEFAULT_OPTS="--layout=reverse --bind=ctrl-z:ignore,ctrl-a:select-all"
  2. fzf_history() {
  3. local selected=$(sed 's/^[^;]*;//' $HISTFILE | \
  4. 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)
  5. local ret=$?
  6. if [ -n "$selected" ]; then
  7. BUFFER="$selected"
  8. fi
  9. zle reset-prompt
  10. return $ret
  11. }
  12. fzf_cd() {
  13. local start=${1:-.}
  14. local selected=$(find "$start" -type d -printf "%P\n" | \
  15. FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf)
  16. local ret=$?
  17. if [ $ret -ne 0 ]; then
  18. return $ret
  19. fi
  20. if [ -n "$selected" ]; then
  21. cd "$start/$selected"
  22. fi
  23. }
  24. zle -N fzf_history