mirror of
https://github.com/jchook/ranger-zoxide.git
synced 2025-12-26 18:34:56 +08:00
Allow running interactively with -i
This commit is contained in:
parent
b03a5f1893
commit
af84a3d580
1 changed files with 9 additions and 4 deletions
13
__init__.py
13
__init__.py
|
|
@ -26,17 +26,22 @@ class z(ranger.api.commands.Command):
|
|||
"""
|
||||
def execute(self):
|
||||
results = self.query(self.args[1:])
|
||||
if not results:
|
||||
return
|
||||
|
||||
if os.path.isdir(results[0]):
|
||||
self.fm.cd(results[0])
|
||||
|
||||
def query(self, args):
|
||||
try:
|
||||
p = Popen(
|
||||
["zoxide", "query"] + self.args[1:],
|
||||
stdout=PIPE,
|
||||
stderr=PIPE
|
||||
p = self.fm.execute_command("zoxide query {}".format(" ".join(self.args[1:])),
|
||||
stdout=PIPE
|
||||
)
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if not stdout:
|
||||
return None
|
||||
|
||||
if p.returncode == 0:
|
||||
output = stdout.decode("utf-8").strip()
|
||||
if output:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue