ranger-cd plugin added

This commit is contained in:
Balint Gyapjas 2017-11-21 13:59:21 +01:00
commit 488c80bfd4
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,9 @@
## ranger-cd
Compatible with ranger 1.4.2 through 1.7.\*
After ranger quits, automatically change the current directory of zsh to the
last visited directory in ranger.
Code comes from a [ranger plugin](https://github.com/ranger/ranger/blob/master/examples/bash_automatic_cd.sh)
for bash, but I find it more convenient to have it as an [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh/) plugin.

View file

@ -0,0 +1,13 @@
# functions
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"
}
# aliases
alias ranger=ranger-cd