Skip to content

Instantly share code, notes, and snippets.

@alesandar
Last active June 8, 2020 13:31
Show Gist options
  • Save alesandar/9fbd1f387cf2224ec0edf2c6298feb1a to your computer and use it in GitHub Desktop.
Save alesandar/9fbd1f387cf2224ec0edf2c6298feb1a to your computer and use it in GitHub Desktop.
function ranger-cd {
tempfile="$(mktemp -t tmp.XXXXXX)"
/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
/usr/bin/rm -f -- "$tempfile"
}
run_ranger() { BUFFER="ranger"; zle accept-line; }
zle -N run_ranger
bindkey '^\er' run_ranger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment