about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorM Rawash <mrawash@gmail.com>2012-01-27 00:14:55 +0200
committerM Rawash <mrawash@gmail.com>2012-01-27 00:14:55 +0200
commit47c2cf6920324da597cf969329c0abb59591c9ca (patch)
tree5c0dff1fc4cac192fdd373277e6b565977d2cdb0
parent9e146c8272e25b98d0f196bc34ac1725f894863a (diff)
downloadranger-47c2cf6920324da597cf969329c0abb59591c9ca.tar.gz
new :relink command
-rw-r--r--doc/ranger.18
-rw-r--r--doc/ranger.pod4
-rw-r--r--ranger/defaults/commands.py39
3 files changed, 51 insertions, 0 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 94d5387d..06b08d50 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -741,6 +741,9 @@ it by typing `` or '' the next time you start ranger.
 .IX Item "rename newname"
 Rename the current file.  If a file with that name already exists, the renaming
 will fail.  Also try the key binding A for appending something to a file name.
+.IP "relink \fInewpath\fR" 2
+.IX Item "relink newpath"
+Change the link destination of the current symlink file to <newpath>. First <tab> will load the original link.
 .IP "save_copy_buffer" 2
 .IX Item "save_copy_buffer"
 Save the copy buffer from \fI~/.config/ranger/copy_buffer\fR.  This can be used to
@@ -869,6 +872,11 @@ program out of \*(L"vim\*(R", \*(L"emacs\*(R" and \*(L"nano\*(R".
 .IX Item "SHELL"
 Defines the shell that ranger is going to use with the :shell command and
 the \*(L"S\*(R" key.  Defaults to \*(L"bash\*(R".
+.IP "\s-1TERMCMD\s0" 8
+.IX Item "TERMCMD"
+Defines the terminal emulator command that ranger is going to use with the
+:terminal command and the \*(L"t\*(R" run flag.  Defaults to \*(L"x\-terminal-emulator\*(R" or
+\&\*(L"xterm\*(R"
 .IP "\s-1XDG_CONFIG_HOME\s0" 8
 .IX Item "XDG_CONFIG_HOME"
 Specifies the directory for configuration files. Defaults to \fI\f(CI$HOME\fI/.config\fR.
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 65615a8e..93b69999 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -787,6 +787,10 @@ it by typing `` or '' the next time you start ranger.
 Rename the current file.  If a file with that name already exists, the renaming
 will fail.  Also try the key binding A for appending something to a file name.
 
+=item relink I<newpath>
+
+Change the link destination of the current symlink file to <newpath>. First <tab> will load the original link.
+
 =item save_copy_buffer
 
 Save the copy buffer from I<~/.config/ranger/copy_buffer>.  This can be used to
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