make fzf_bring do what it should do (#434)

also removed a few unnecessary imports
This commit is contained in:
Sean Breckenridge 2019-12-16 05:22:14 -08:00 committed by Luke Smith
parent fc3aae4235
commit 29bee71d65

View file

@ -6,6 +6,7 @@
# You always need to import ranger.api.commands here to get the Command class: # You always need to import ranger.api.commands here to get the Command class:
from ranger.api.commands import * from ranger.api.commands import *
from ranger.core.loader import CommandLoader
# A simple command for demonstration purposes follows. # A simple command for demonstration purposes follows.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -88,6 +89,8 @@ class fzf_select(Command):
self.fm.cd(fzf_file) self.fm.cd(fzf_file)
else: else:
self.fm.select_file(fzf_file) self.fm.select_file(fzf_file)
# fzf_locate # fzf_locate
class fzf_locate(Command): class fzf_locate(Command):
""" """
@ -114,6 +117,7 @@ class fzf_locate(Command):
else: else:
self.fm.select_file(fzf_file) self.fm.select_file(fzf_file)
class fzf_bring(Command): class fzf_bring(Command):
""" """
:fzf_bring :fzf_bring
@ -124,6 +128,7 @@ class fzf_bring(Command):
""" """
def execute(self): def execute(self):
import subprocess import subprocess
import shutil
if self.quantifier: if self.quantifier:
# match only directories # match only directories
command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
@ -136,15 +141,9 @@ class fzf_bring(Command):
stdout, stderr = fzf.communicate() stdout, stderr = fzf.communicate()
if fzf.returncode == 0: if fzf.returncode == 0:
fzf_file = os.path.abspath(stdout.decode('utf-8').rstrip('\n')) fzf_file = os.path.abspath(stdout.decode('utf-8').rstrip('\n'))
if os.path.isdir(fzf_file): shutil.move(fzf_file, self.fm.thisdir.path)
self.fm.cd(fzf_file)
else:
self.fm.select_file(fzf_file)
import os
from ranger.core.loader import CommandLoader
class compress(Command): class compress(Command):
def execute(self): def execute(self):
""" Compress marked files to current directory """ """ 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] 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): class extracthere(Command):
def execute(self): def execute(self):
""" Extract copied files to current directory """ """ Extract copied files to current directory """
@ -212,5 +206,3 @@ class extracthere(Command):
obj.signal_bind('after', refresh) obj.signal_bind('after', refresh)
self.fm.loader.add(obj) self.fm.loader.add(obj)