summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2016-03-21 12:02:17 +0100
committerCiro Santilli <ciro.santilli@gmail.com>2016-03-21 12:02:17 +0100
commitf6bdde502d0a08f80783e4035d09543f821bc72a (patch)
treecb56fec21c1393daa3defe899b8c775dec530555
parent09c30cdf4b9050d548e12b5108581680357ac5f1 (diff)
downloadranger-f6bdde502d0a08f80783e4035d09543f821bc72a.tar.gz
set_bookmark for directories other than the current
Sample usage:

    :set_bookmark a /home/me/a

Motivation: make it easier to set bookmarks from environment variables
on rc.conf.
-rw-r--r--ranger/core/actions.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 89924dc0..32b8925e 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -23,6 +23,7 @@ from ranger.ext.next_available_filename import next_available_filename
 from ranger.ext.rifle import squash_flags, ASK_COMMAND
 from ranger.core.shared import FileManagerAware, SettingsAware
 from ranger.core.tab import Tab
+from ranger.container.directory import Directory
 from ranger.container.file import File
 from ranger.core.loader import CommandLoader, CopyLoader
 from ranger.container.settings import ALLOWED_SETTINGS
@@ -782,10 +783,14 @@ class Actions(FileManagerAware, SettingsAware):
         except KeyError:
             pass
 
-    def set_bookmark(self, key):
+    def set_bookmark(self, key, val=None):
         """Set the bookmark with the name <key> to the current directory"""
+        if val is None:
+            val = self.thisdir
+        else:
+            val = Directory(val)
         self.bookmarks.update_if_outdated()
-        self.bookmarks[str(key)] = self.thisdir
+        self.bookmarks[str(key)] = val
 
     def unset_bookmark(self, key):
         """Delete the bookmark with the name <key>"""