summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-03 00:12:38 +0200
committerhut <hut@lavabit.com>2010-10-03 00:12:38 +0200
commite30d1c7860c9017f8485f35130e65eb7f60ceda8 (patch)
treec460b68be07e323cbd5c82b1b1c95e0524fc5461 /ranger
parentfabec26d0e3f947cfc0f73bdea40bd1694e3adff (diff)
downloadranger-e30d1c7860c9017f8485f35130e65eb7f60ceda8.tar.gz
defaults.commands: new commands :{load,save}_copy_buffer
These allow you to share copy buffers between ranger instances.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/commands.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index e66d2c24..b143762a 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -436,6 +436,42 @@ class mark(Command):
 		self.fm.ui.need_redraw = True
 
 
+class load_copy_buffer(Command):
+	"""
+	:load_copy_buffer
+
+	Load the copy buffer from confdir/copy_buffer
+	"""
+	copy_buffer_filename = 'copy_buffer'
+	def execute(self):
+		from ranger.fsobject import File
+		from os.path import exists
+		try:
+			f = open(self.fm.confpath(self.copy_buffer_filename), 'r')
+		except:
+			return self.fm.notify("Cannot open file %s" % fname, bad=True)
+		self.fm.env.copy = set(File(g) \
+			for g in f.read().split("\n") if exists(g))
+		f.close()
+		self.fm.ui.redraw_main_column()
+
+
+class save_copy_buffer(Command):
+	"""
+	:save_copy_buffer
+
+	Save the copy buffer to confdir/copy_buffer
+	"""
+	copy_buffer_filename = 'copy_buffer'
+	def execute(self):
+		try:
+			f = open(self.fm.confpath(self.copy_buffer_filename), 'w')
+		except:
+			return self.fm.notify("Cannot open file %s" % fname, bad=True)
+		f.write("\n".join(f.path for f in self.fm.env.copy))
+		f.close()
+
+
 class unmark(mark):
 	"""
 	:unmark <regexp>