Skip to content

Instantly share code, notes, and snippets.

@ha7ilm
Created July 31, 2016 11:02
Show Gist options
  • Save ha7ilm/37c4272b1df6fbfdb0df30464252241e to your computer and use it in GitHub Desktop.
Save ha7ilm/37c4272b1df6fbfdb0df30464252241e to your computer and use it in GitHub Desktop.
ranger-cd for zsh
#This is based on: https://github.com/ranger/ranger/blob/master/examples/bash_automatic_cd.sh
#Paste this into your .zshrc:
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
rm -f -- "$tempfile"
}
bindkey -s '^O' 'ranger-cd\n'
#ranger-cd will fire for Ctrl+O
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment