Created
July 31, 2016 11:02
-
-
Save ha7ilm/37c4272b1df6fbfdb0df30464252241e to your computer and use it in GitHub Desktop.
ranger-cd for zsh
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
#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