-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Automatically insert newline in bash command line completion #222
Comments
Hmm, I don't think the behavior is generally desirable. Take this for example: you want to copy/move several files from different directories to some destination path.
It's simply not possible to tell if the completed word will be the last argument to the command. |
Yes I agree that in the general case it not possible and not desirable. But if we consider specific cases, for example if I make my own command and would try to use fzf for command line completion. Then I would have full controll over what is the expected arguments, and whether the completed word will be the last one, when I am calling fzf.. So we are looking for a way to feed an enter key into Bash command from a Bash completion function.. |
Yes, and maybe we could apply |
seems like running
after fzf returns, is working.. I will do some more testing. |
+1 would be great to have alternate key that I can press that would paste selection followed by newline to shell |
If you just wish fzf to execute the selected command immediately, how about writing a shell script along the lines of dmenu_run? Something along the lines of #!/bin/sh Or another script for opening files: |
This may not be explicitly related to bash completion, but considering this is the only link that comes up when searching for fzf + automatic carriage return and related, quick reminder to others that you can add a \C-m to the end of your key-bindings to automatically hit enter Eg:
Remember, there are two sections with these bindings defined (depending on whether you use set -o vi). |
@ConSeannery The problem with the approach is that you can no longer edit the command. On zsh it's possible to use bind "$(bind -s | grep '^"\\C-r"' | sed 's/"/"\\C-x/' | sed 's/"$/\\C-m"/')" |
Is it possible to insert an enter key stroke after fzf returns with a single candidate in bash completion?
I am thinking about the case where the completed word is the last word on a command line, such that the next ting the user will do is to accept and execute the command by pressing enter.
Usually in bash completion when you press tab and there is only a single candidate, it will insert the candidate directly as replacement for the current word on the command line. Then, if this is the last possible word on the command line, you would press enter to accept. It is ok and correct to have to confirm with pressing the enter key in this case.
However, when I use fzf to select a candidate, I first press enter first to select the candidate in fzf, but when returning to the command line, I have to press enter again to execute the command. It feels like I have to accept the same candidate twice.. And it is distracting my workflow..
I am not say that this should be the general behavior; only if the completed word is last on the line, there should be an option to have the command be exectued immediately by pressing enter in fzf..
Any thoughts about this issue?
The text was updated successfully, but these errors were encountered: