summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.124
-rw-r--r--doc/ranger.pod20
-rwxr-xr-xranger.py12
3 files changed, 31 insertions, 25 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 6cc2b5e4..981aa115 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.4.3" "09/25/2011" "ranger manual"
+.TH RANGER 1 "ranger-1.4.3" "09/28/2011" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -707,20 +707,22 @@ opening in your current vim session.
 .Ve
 .SS "Bash: cd to last path after exit"
 .IX Subsection "Bash: cd to last path after exit"
-This is a bash function (to put in your \fI~/.bashrc\fR) to change the directory
-to the last visited one after ranger quits.  You can always type \f(CW\*(C`cd \-\*(C'\fR to go
-back to the original one.
+This is a bash function (for \fI~/.bashrc\fR) to change the directory to the last
+visited one after ranger quits.  You can always type \f(CW\*(C`cd \-\*(C'\fR to go back to the
+original one.
 .PP
-.Vb 9
+.Vb 8
 \& function ranger\-cd {
-\&   tempfile=/tmp/chosendir
-\&   /usr/bin/ranger \-\-choosedir=$tempfile "$@"
-\&   if [ \-f $tempfile \-a "$(cat $tempfile)" != "$(pwd | tr \-d "\en")" ]
-\&   then
-\&     cd "$(cat $tempfile)"
-\&     rm $tempfile
+\&   tempfile=\*(Aq/tmp/chosendir\*(Aq
+\&   /usr/bin/ranger \-\-choosedir="$tempfile" "${@:\-$(pwd)}"
+\&   if [ \-f "$tempfile" \-a "$(cat "$tempfile")" != "$(pwd | tr \-d "\en")" ]; then
+\&     cd "$(cat "$tempfile")"
+\&     rm "$tempfile"
 \&   fi
 \& }
+\&
+\& # This binds Ctrl\-O to ranger\-cd:
+\& bind \*(Aq"\eC\-o":"ranger\-cd\eC\-m"\*(Aq
 .Ve
 .SH "LICENSE"
 .IX Header "LICENSE"
diff --git a/doc/ranger.pod b/doc/ranger.pod
index f6dbdb60..b59f7a40 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -778,20 +778,22 @@ opening in your current vim session.
 
 =head2 Bash: cd to last path after exit
 
-This is a bash function (to put in your F<~/.bashrc>) to change the directory
-to the last visited one after ranger quits.  You can always type C<cd -> to go
-back to the original one.
+This is a bash function (for F<~/.bashrc>) to change the directory to the last
+visited one after ranger quits.  You can always type C<cd -> to go back to the
+original one.
 
  function ranger-cd {
-   tempfile=/tmp/chosendir
-   /usr/bin/ranger --choosedir=$tempfile "$@"
-   if [ -f $tempfile -a "$(cat $tempfile)" != "$(pwd | tr -d "\n")" ]
-   then
-     cd "$(cat $tempfile)"
-     rm $tempfile
+   tempfile='/tmp/chosendir'
+   /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
+   if [ -f "$tempfile" -a "$(cat "$tempfile")" != "$(pwd | tr -d "\n")" ]; then
+     cd "$(cat "$tempfile")"
+     rm "$tempfile"
    fi
  }
 
+ # This binds Ctrl-O to ranger-cd:
+ bind '"\C-o":"ranger-cd\C-m"'
+
 
 
 
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"
n296' href='#n296'>296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381