From 29bee71d652cd62190b4934817ee227a6f9340d2 Mon Sep 17 00:00:00 2001 From: Sean Breckenridge Date: Mon, 16 Dec 2019 05:22:14 -0800 Subject: [PATCH] make fzf_bring do what it should do (#434) also removed a few unnecessary imports --- .config/ranger/commands.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.config/ranger/commands.py b/.config/ranger/commands.py index 8c5e748..71fd2a2 100755 --- a/.config/ranger/commands.py +++ b/.config/ranger/commands.py @@ -6,6 +6,7 @@ # You always need to import ranger.api.commands here to get the Command class: from ranger.api.commands import * +from ranger.core.loader import CommandLoader # A simple command for demonstration purposes follows. #------------------------------------------------------------------------------ @@ -88,6 +89,8 @@ class fzf_select(Command): self.fm.cd(fzf_file) else: self.fm.select_file(fzf_file) + + # fzf_locate class fzf_locate(Command): """ @@ -114,6 +117,7 @@ class fzf_locate(Command): else: self.fm.select_file(fzf_file) + class fzf_bring(Command): """ :fzf_bring @@ -124,6 +128,7 @@ class fzf_bring(Command): """ def execute(self): import subprocess + import shutil if self.quantifier: # match only directories command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ @@ -136,15 +141,9 @@ class fzf_bring(Command): stdout, stderr = fzf.communicate() if fzf.returncode == 0: fzf_file = os.path.abspath(stdout.decode('utf-8').rstrip('\n')) - if os.path.isdir(fzf_file): - self.fm.cd(fzf_file) - else: - self.fm.select_file(fzf_file) + shutil.move(fzf_file, self.fm.thisdir.path) -import os -from ranger.core.loader import CommandLoader - class compress(Command): def execute(self): """ Compress marked files to current directory """ @@ -176,11 +175,6 @@ class compress(Command): return ['compress ' + os.path.basename(self.fm.thisdir.path) + ext for ext in extension] - - -import os -from ranger.core.loader import CommandLoader - class extracthere(Command): def execute(self): """ Extract copied files to current directory """ @@ -212,5 +206,3 @@ class extracthere(Command): obj.signal_bind('after', refresh) self.fm.loader.add(obj) - -