summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
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"