-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use fzf to navigate through completion proposals #10
base: main
Are you sure you want to change the base?
Conversation
note: code formatting using `black`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Please note that this repo is mostly unmaintained, as autojump
itself doesn't seem maintained anymore.
However, I had a look at your changes and I like the general idea :)
|
||
if autojump.returncode == 0: | ||
if autojump_stdout.rstrip("\n"): | ||
fzf = self.fm.execute_command( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're executing the same exact command a second time? Can't we just send the results from the first run to fzf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there's probably a better way to do it
directory = subprocess.check_output(["autojump", self.arg(1)]) | ||
directory = directory.decode("utf-8", "ignore") | ||
directory = directory.rstrip("\n") | ||
self.fm.cd(directory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do an early return to save some indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, if fzf is absent, an action must still be performed.
universal_newlines=True, | ||
stdout=subprocess.PIPE, | ||
) | ||
fzf_stdout, fzf_stderr = fzf.communicate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there are more modern way to do this? The first branch uses subprocess
directly, maybe we can align all of them and get rid of communicate
? Or is this the recommended way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't know much about python ;-) , but reading the documentation, there are ways to make things simpler.
self.fm.cd(fzf_file_path) | ||
else: | ||
self.fm.select_file(fzf_file_path) | ||
else: # sdtout is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do the same handling in the first branch, without fzf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a priori no, because in this first case we don't try to navigate through the proposals, we jump directly to the path with the highest weight in the history
) | ||
fzf_stdout, fzf_stderr = fzf.communicate() | ||
|
||
if fzf.returncode == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, the user should be notified of the error
First of all, thank you for taking the time to provide this detailed feedback :-). There are a lot of little things to review. I'll update this first version as soon as possible. |
Hello,
I've extended the script to allow navigation through the possible completions proposed by
autojump
in casefzf
is present in the PATH.