Skip to content

Instantly share code, notes, and snippets.

View Enzime's full-sized avatar
❄️
Nixing into the night

Michael Hoang Enzime

❄️
Nixing into the night
View GitHub Profile
@Enzime
Enzime / Zsh: change directory using ranger
Last active August 29, 2015 14:27 — forked from dbohdan/Zsh: change directory using ranger
Adopted from the "Bash: cd to last path after exit" example in the man page for ranger(1).
ranger-cd() {
tempfile=$(mktemp)
ranger --choosedir="$tempfile" "${@:-$(pwd)}" < $TTY
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
# hacky way of transferring over previous command and updating the screen
VISUAL=true zle edit-command-line