From 0c814c5dced3f20a53606e9c0fabaaf04c95f2cc Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Thu, 25 Jul 2013 22:19:54 +0200 Subject: [PATCH] Ranger: shell browser and tab_new in current dir --- .config/ranger/rc.conf | 5 ++++- .shell.d/funs_rc | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index 593e6c14..6291ab45 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -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 eval fm.tab_new('%d') \ No newline at end of file diff --git a/.shell.d/funs_rc b/.shell.d/funs_rc index b0a610dd..08799360 100644 --- a/.shell.d/funs_rc +++ b/.shell.d/funs_rc @@ -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 ##==============================================================================