Created
November 23, 2015 05:13
-
-
Save adamheins/451098af486df1722291 to your computer and use it in GitHub Desktop.
A modification to the fzf key-bindings file that makes ALT-C both cd to directories and open files.
This file contains 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
# ALT-C - cd into the selected directory or open file | |
fzf-cd-widget() { | |
local p="${$(command \find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ | |
-o -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m):-.}" | |
if [ -d "$p" ]; then | |
cd "$p" | |
elif [ -f "$p" ]; then | |
"$EDITOR" < /dev/tty "$p" | |
else | |
echo "$p" | |
fi | |
zle reset-prompt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment