summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-18 17:22:02 +0100
committerhut <hut@lavabit.com>2010-01-18 17:22:02 +0100
commit2c1d2db0894cd9578bbd9665dee71ae984131208 (patch)
tree216c0778569cd19a0a01f7d66e0361a4af249a81
parent89ce1b0101c8cea1163af0b360f991a2bd37d57b (diff)
downloadranger-2c1d2db0894cd9578bbd9665dee71ae984131208.tar.gz
actions: bookmark old dir in ` when using :cd
-rw-r--r--TODO2
-rw-r--r--ranger/actions.py15
-rw-r--r--ranger/commands.py2
-rw-r--r--ranger/defaults/keys.py26
4 files changed, 25 insertions, 20 deletions
diff --git a/TODO b/TODO
index a94db1ee..83d41fec 100644
--- a/TODO
+++ b/TODO
@@ -31,7 +31,7 @@ General
    ( ) #37  10/01/13  better tab completion for OpenConsole
    ( ) #38  10/01/16  searching in pager
    ( ) #39  10/01/17  flushinput now always good
-   ( ) #42  10/01/17  memorize directory for `` when using :cd
+   (X) #42  10/01/17  memorize directory for `` when using :cd
    ( ) #43  10/01/18  internally treat the bookmarks ` and ' the same
 
 
diff --git a/ranger/actions.py b/ranger/actions.py
index 6aab4581..91216ab7 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -81,10 +81,19 @@ class Actions(EnvironmentAware, SettingsAware):
 		"""Exit the program"""
 		raise SystemExit()
 
-	def enter_dir(self, path):
+	def enter_dir(self, path, remember=False):
 		"""Enter the directory at the given path"""
+		if remember:
+			pwd = self.env.pwd
+			result = self.env.enter_dir(path)
+			self.bookmarks.remember(pwd)
+			return result
 		return self.env.enter_dir(path)
 
+	def cd(self, path, remember=True):
+		"""enter the directory at the given path, remember=True"""
+		self.enter_dir(path, remember)
+
 	def tag_toggle(self, movedown=None):
 		try:
 			toggle = self.tags.toggle
@@ -487,7 +496,3 @@ class Actions(EnvironmentAware, SettingsAware):
 			os.rename(src, dest)
 		except OSError as err:
 			self.notify(str(err), bad=True)
-
-	# ------------------------------------ aliases
-
-	cd = enter_dir
diff --git a/ranger/commands.py b/ranger/commands.py
index 3bf65096..ea8e41f4 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -156,7 +156,7 @@ class cd(Command):
 		if destination == '-':
 			self.fm.enter_bookmark('`')
 		else:
-			self.fm.enter_dir(destination)
+			self.fm.cd(destination)
 
 	def tab(self):
 		return self._tab_only_directories()
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 5aa49073..b11cd85a 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -138,19 +138,19 @@ def initialize_commands(command_list):
 	hint('d', 'd//u// (disk usage) d//d// (cut)')
 
 	# --------------------------------------------- jump to directories
-	bind('gh', fm.enter_dir('~'))
-	bind('ge', fm.enter_dir('/etc'))
-	bind('gu', fm.enter_dir('/usr'))
-	bind('gd', fm.enter_dir('/dev'))
-	bind('gl', fm.enter_dir('/lib'))
-	bind('go', fm.enter_dir('/opt'))
-	bind('gv', fm.enter_dir('/var'))
-	bind('gr', 'g/', fm.enter_dir('/'))
-	bind('gm', fm.enter_dir('/media'))
-	bind('gn', fm.enter_dir('/mnt'))
-	bind('gt', fm.enter_dir('/tmp'))
-	bind('gs', fm.enter_dir('/srv'))
-	bind('gR', fm.enter_dir(RANGERDIR))
+	bind('gh', fm.cd('~'))
+	bind('ge', fm.cd('/etc'))
+	bind('gu', fm.cd('/usr'))
+	bind('gd', fm.cd('/dev'))
+	bind('gl', fm.cd('/lib'))
+	bind('go', fm.cd('/opt'))
+	bind('gv', fm.cd('/var'))
+	bind('gr', 'g/', fm.cd('/'))
+	bind('gm', fm.cd('/media'))
+	bind('gn', fm.cd('/mnt'))
+	bind('gt', fm.cd('/tmp'))
+	bind('gs', fm.cd('/srv'))
+	bind('gR', fm.cd(RANGERDIR))
 
 	# ------------------------------------------------------- searching
 	bind('/', fm.open_console(cmode.SEARCH))