Last active
September 7, 2016 15:23
-
-
Save RyanScottLewis/eecdeff43fa2d7e65df14ba83df045ca to your computer and use it in GitHub Desktop.
Ranger Bash/Zsh Integration
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
function ranger-cd { | |
tempfile="$(mktemp -t tmp.XXXXXX)" | |
$(which ranger) --choosedir="$tempfile" "${@:-$(pwd)}" | |
test -f "$tempfile" && | |
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then | |
cd -- "$(cat "$tempfile")" | |
fi | |
rm -f -- "$tempfile" | |
} | |
bind '"\C-o":"ranger-cd\C-m"' |
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
function ranger-cd { | |
tempfile="$(mktemp -t tmp.XXXXXX)" | |
$(which ranger) --choosedir="$tempfile" "${@:-$(pwd)}" | |
test -f "$tempfile" && | |
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then | |
cd -- "$(cat "$tempfile")" | |
fi | |
rm -f -- "$tempfile" | |
} | |
bindkey -s "\C-O" '^qranger-cd\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment