Created
August 17, 2013 16:15
-
-
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).
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
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