Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Last active September 7, 2016 15:23
Show Gist options
  • Save RyanScottLewis/eecdeff43fa2d7e65df14ba83df045ca to your computer and use it in GitHub Desktop.
Save RyanScottLewis/eecdeff43fa2d7e65df14ba83df045ca to your computer and use it in GitHub Desktop.
Ranger Bash/Zsh Integration
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"'
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