summary refs log tree commit diff stats
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
parent30f17d752f75f5950315e328b21bff50eac86ab4 (diff)
parent47c2cf6920324da597cf969329c0abb59591c9ca (diff)
downloadranger-25dfd676d7211865d2ee0f6af2ce9ef19a6c8dcf.tar.gz
Merge git://github.com/gwash/ranger
-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