Skip to content

Instantly share code, notes, and snippets.

@dbohdan
Created August 17, 2013 16:15
Show Gist options
  • Save dbohdan/6257642 to your computer and use it in GitHub Desktop.
Save dbohdan/6257642 to your computer and use it in GitHub Desktop.
Adopted from the "Bash: cd to last path after exit" example in the man page for ranger(1).
ranger-cd() {
tempfile=$(mktemp)
ranger --choosedir="$tempfile" "${@:-$(pwd)}" < $TTY
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
# This binds Ctrl-O to ranger-cd:
zle -N ranger-cd
bindkey '^o' ranger-cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment