Created
August 3, 2016 21:32
-
-
Save iammerrick/afd08241030b6fdc9cdb998b52fb62b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CTRL-P - cd into the selected directory | |
# | |
__fzfcmd() { | |
[ ${FZF_TMUX:-1} -eq 1 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" | |
} | |
fzf-cd-widget() { | |
local cmd="${FZF_CTRL_P_COMMAND:-"command find -L ~ \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ | |
-o -type d -print 2> /dev/null | sed 1d"}" | |
setopt localoptions pipefail 2> /dev/null | |
cd "${$(eval "$cmd | $(__fzfcmd) +m $FZF_CTRL_P_OPTS"):-.}" | |
local ret=$? | |
zle reset-prompt | |
typeset -f zle-line-init >/dev/null && zle zle-line-init | |
return $ret | |
} | |
zle -N fzf-cd-widget | |
bindkey "^P" fzf-cd-widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from bindings provided by fzf