summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-09-28 20:15:12 +0200
committerhut <hut@lavabit.com>2011-09-28 20:15:12 +0200
commitee254689207889e68061f0680f4d6ac47d5ed408 (patch)
tree48b0b4eeb0cbec915339e0c2b65ca3c9ed307c9f /ranger.py
parent496c00d4200ff25c833bbaf03ee04a6031d83b92 (diff)
downloadranger-ee254689207889e68061f0680f4d6ac47d5ed408.tar.gz
improved bash wrappers in ranger.py and man page
Diffstat (limited to 'ranger.py')
-rwxr-xr-xranger.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/ranger.py b/ranger.py
index 53fd8bdb..c4f68923 100755
--- a/ranger.py
+++ b/ranger.py
@@ -21,11 +21,13 @@
 # after you exit ranger.  Run it with the command: source ranger ranger
 """":
 if [ ! -z "$1" ]; then
-	$@ --fail-unless-cd &&
-	if [ -z "$XDG_CONFIG_HOME" ]; then
-		cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
-	else
-		cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
+	tempfile='/tmp/chosendir'
+	ranger="$1"
+	shift
+	"$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
+	if [ -f "$tempfile" -a "$(cat "$tempfile")" != "$(pwd | tr -d "\n")" ]; then
+		cd "$(cat "$tempfile")"
+		rm "$tempfile"
 	fi && return 0
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"