-
-
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
Allow for alternate key bindings #546
Comments
Technically CTRL-T is not an OS X feature, but a default key binding of bash that is mapped to "transpose-chars" (see Excerpt from https://www.iterm2.com/faq.html:
I use |
Well, if we want to get all technical, these are Emacs-style readline bindings, but the Cocoa text system makes a slightly modified subset of them available in all Cocoa text fields (no Meta combinations, but As to the meta key configuration, I’m not using iTerm (and don’t intend to – there are only so many configuration time sinks I am willing to invest into ;)), but I think Terminal.app allows for usage of Escape as Meta too. Thanks for the hint! |
You use bash so you currently can do this: [ -f ~/.fzf.bash ] && source ~/.fzf.bash
# Remap CTRL-T to CTRL-X CTRL-T
bind "$(bind -s | grep __fzf_select | sed 's/\\C-t/\\C-x\\C-t/')"
bind '"\C-t": transpose-chars' |
Yeah, I can hack my way around this (in fact, the first thing I did before posting this issue was looking into key-bindings.bash), but this is both brittle (it depends on internal implementation details) and non-portable (I’ll have to redo it should I switch shells, say to I’m wondering if a possible way to address this might be introducing an intermediary binding (e.g. |
Interesting idea but the suggested approach does not completely solve the problem of portability you mentioned. bash, zsh, and fish all use different syntaxes for binding keys. Changing the binding is much more pleasant on zsh: bindkey '^X^T' fzf-file-widget
bindkey '^T' transpose-chars on bash 4 (I'm stuck with bash 3) bind -x '"\C-x\C-t": "__fzf_select_tmux_auto__"'
bind '"\C-t": transpose-chars' and on fish bind \cx\ct __fzf_ctrl_t
bind \ct transpose-chars Looking at the above snippets, it looks like what we can do is to use the consistent name |
Sounds good; I’ll take straightforward, stable configurability over portability if I have to choose. |
- fzf-file-widget - fzf-history-widget - fzf-cd-widget
e.g. Remapping fzf-file-widget to CTRL-X CTRL-T intead of CTRL-T bind -x '"\C-x\C-t": fzf-file-widget' bind '"\C-t": transpose-chars'
Updated the code. Now on bash 4+ you can bind -x '"\C-x\C-t": fzf-file-widget'
bind '"\C-t": transpose-chars' However, unfortunately, CTRL-R and ALT-C are left untouched for the following reasons
I'll close the issue for now as we still have workarounds. But pull requests are appreciated. |
FWIW, I too found it a bit annoying that fzf clobbered ctrl-t. Having to recreate the mapping after fzf clobbered it seems a bit roundabout. Maybe there could be some env var that when set prevents fzf from overwriting ctrl-t in the first place? |
FYI, to bind (aka shortcut or remap) keystrokes in bash follow: https://stackoverflow.com/questions/4200800/in-bash-how-do-i-bind-a-function-key-to-a-command/4201274#4201274 |
These bindings work great for me:
I have the best of vim and emacs/readline in my terminal! |
For those using bash with vi bindings, and who don't like it that You can disable the binding like this in your bind -r '\ec' |
Does fzf currently override any stock Bash functionality, aside from |
Two out of three of
fzf
’s key bindings conflict with OS X features:Ctrl-T
clobbers the “transpose” function of the Cocoa text system ordinarily bound to that key; too useful a feature to simply lose forfzf
usage.Alt-C
does not work at all, as Alt+letter combinations insert special characters (“ç” on a German keyboard); disabling that is not even an option for anybody writing in a language other than English on OS X.Providing either a way to configure these bindings (not just opt out on install – the hotkeys are useful after all), or saner defaults on OS X would be much appreciated.
The text was updated successfully, but these errors were encountered: