mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-06-05 05:03:16 +02:00
ranger-cd plugin added
This commit is contained in:
parent
e273cf004e
commit
488c80bfd4
2 changed files with 22 additions and 0 deletions
9
plugins/ranger-cd/README.md
Normal file
9
plugins/ranger-cd/README.md
Normal 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.
|
||||||
13
plugins/ranger-cd/ranger-cd.plugin.zsh
Normal file
13
plugins/ranger-cd/ranger-cd.plugin.zsh
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue