Ranger: shell browser and tab_new in current dir

master
Pierre Neidhardt 2013-07-25 22:19:54 +02:00
parent c4c1fe9fb2
commit 0c814c5dce
2 changed files with 22 additions and 1 deletions

View File

@ -145,6 +145,9 @@ map ea shell cmus-remote -P %s
map em shell fuseiso -p %f ~/iso
map eu shell fusermount -qu ~/iso
# Quick moves
## Quick moves
map K move up=5
map J move down=5
## New tab in current folder. Use 'gn' for home folder.
map <c-n> eval fm.tab_new('%d')

View File

@ -407,6 +407,24 @@ clonecd ()
# dd if=$DRIVE of='$1.iso' bs=2048 count=$(isosize -d 2048 $DRIVE) conv=sync,notrunc
}
browse ()
{
# Compatible with ranger 1.4.2 through 1.6.*
#
# Automatically change the directory in bash after closing ranger
#
# This is a shell wrapper script to automatically change the directory to the
# last visited one after ranger quits. To undo the effect of this function, you
# can type "cd -" to return to the original directory.
tempfile="$(mktemp)"
/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
if [ -f "$tempfile" ] && [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
##==============================================================================
## Pacman functions
##==============================================================================