-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[bash] Fire command directly with CTRL-X in CTRL-R #1492
Conversation
Thanks for your interest in the project. Due to increasing maintenance burden, I decided not to add more options to the key bindings this repository provides. Ensuring consistent, stable user experience across three different shells – bash, zsh, and fish – turned out to be quite painful and has taken up much of my time. So instead of having this merged to this repository, I suggest that you create a separate "plugin" with extended features and options, so that the users can optionally install your bindings if they want. [ -f ~/.fzf.bash ] && source ~/.fzf.bash
# Load your plugin to override the bindings |
If you turned this into a plugin, I'd love to use it. Could you share a link here so other Google-searchers can find it? |
import from https://github.com/4z3/fzf/blob/78d0e8c as requested in junegunn/fzf#1492
import from https://github.com/4z3/fzf/blob/78d0e8c as requested in junegunn/fzf#1492
import from https://github.com/4z3/fzf/blob/78d0e8c as requested in junegunn/fzf#1492
import from https://github.com/4z3/fzf/blob/78d0e8c as requested in junegunn/fzf#1492
This PR's code has been copied to 4z3/fzf-plugins. |
This was quite easy in zsh. |
Finally fzf widget that accept key bindings REFERENCE junegunn/fzf/issues/745 junegunn/fzf/issues/1552 junegunn/fzf/pull/1492 junegunn/fzf/wiki/examples https://www.geeksforgeeks.org/array-basics-shell-scripting-set-1/ http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
This PR adds the ability to choose between direct execution and prior editing in CTRL-R for bash.
I'm not sure whether this implementation is acceptable as it is quite hacky and requires two dedicated readline bindings, but as demand for this feature seemed quite high, I've created a PR anyway =)
The trick used is to bind a command (to CTRL-O) that inspects the readline buffer and rebinds another binding (CTRL-P) to either accept a line or do nothing. The rebinding happens if the readline buffer contains a "magic suffix".
__fzf_history__
, in turn, adds the suffix based on the key used to make a selection. By default Enter allows the user to edit the selection, and CTRL-X will execute it immediately, i.e the same way it was proposed for zsh. As some users (me included) prefer to execute by default instead, the keys to choose between execution and editing have been made configurable, e.g.:Related #477