summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-01-26 23:32:29 +0100
committerhut <hut@lavabit.com>2012-01-26 23:32:29 +0100
commit25dfd676d7211865d2ee0f6af2ce9ef19a6c8dcf (patch)
treeca1ac63ad627e86aebd814b63d1eb10191e963f4 /ranger
parent30f17d752f75f5950315e328b21bff50eac86ab4 (diff)
parent47c2cf6920324da597cf969329c0abb59591c9ca (diff)
downloadranger-25dfd676d7211865d2ee0f6af2ce9ef19a6c8dcf.tar.gz
Merge git://github.com/gwash/ranger
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/commands.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index c9729999..d1f4cf16 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -818,6 +818,45 @@ class bulkrename(Command):
 		cmdfile.close()
 
 
+class relink(Command):
+	"""
+	:relink <newpath>
+
+	Changes the linked path of the currently highlighted symlink to <newpath>
+	"""
+
+	def execute(self):
+		from ranger.fsobject import File
+
+		new_path = self.rest(1)
+		cf = self.fm.env.cf
+
+		if not new_path:
+			return self.fm.notify('Syntax: relink <newpath>', bad=True)
+
+		if not cf.is_link:
+			return self.fm.notify('%s is not a symlink!' % cf.basename, bad=True)
+			
+		if new_path == os.readlink(cf.path):
+			return
+		
+		try:
+			os.remove(cf.path)
+			os.symlink(new_path, cf.path)
+		except OSError as err:
+			self.fm.notify(err)
+
+		self.fm.reset()
+		self.fm.env.cwd.pointed_obj = cf
+		self.fm.env.cf = cf
+
+	def tab(self):
+		if not self.rest(1):
+			return self.line+os.readlink(self.fm.env.cf.path)
+		else:
+			return self._tab_directory_content()
+
+
 class help_(Command):
 	"""
 	:help