From e30d1c7860c9017f8485f35130e65eb7f60ceda8 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 3 Oct 2010 00:12:38 +0200 Subject: defaults.commands: new commands :{load,save}_copy_buffer These allow you to share copy buffers between ranger instances. --- ranger/defaults/commands.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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 -- cgit 1.4.1-2-gfad0