Skip to content

Instantly share code, notes, and snippets.

@adamheins
Created November 23, 2015 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamheins/451098af486df1722291 to your computer and use it in GitHub Desktop.
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.
# 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