Since I have my Caps-lock key mapped to Esc (due to Vim), I'd also like it in tmux.
Specifically, I'm trying to set Esc + a as the prefix:
set -g prefix Escape-a
However, this isn't working, and I get the error bad key: Escape-a. Is this because Esc is not a modifier key? I'd really like this to work, as Esc is on the home row and very convenient to use.
This sequence:
set-option -g prefix Escape
unbind-key C-b
bind-key Escape send-prefix
...works for me. I'm using tmux-2.0
If you're on OS X you can achieve this with karabiner.
In your system preferences, change Caps-lock to Control instead of Esc. Then use karabiner to send Esc when you type Control by itself.
karabiner preferences -> "Change Key" tab
scroll down to "Change Control_L Key (Left Control)"
check "Control_L to Control_L (+ When you type Control_L only, send Escape)"
This gives your left pinky easy access to both Esc and Control. You can exit Vim's insert mode the way you already are, and you can set Control+a as your tmux prefix:
set -g prefix C-a
I think this is not possible because Esc and a are 2 distinct keys. From what I know tmux doesn't allow key bindings with more than 1 key (for anything).
This is different from having, for example Ctrl-a as a prefix. Even though we type 2 keyboard keys to get it - ^A is represented as a single character by both tmux and vim.
Related
In zsh-autosuggestions the TAB key accepts the suggestion but then also tries providing more suggestions, which is a difference in behaviour from fish-shell.
In fish if you Tab it completes the word and doesn't offer anything else until you start typing something more (ie suggestions aren't triggered on whitespace).
In zsh-autosuggestions, you can only get this behaviour by using the → key.
So how can I remap the → to behave like Tab (or alternatively how can I remap Tab to behave like →).
Thanks
from the docs:
bindkey '^ ' autosuggest-accept
my setting, which binds ctrl+space to accept then execute the suggestion:
bindkey '^ ' autosuggest-execute
In basic iterm2, multi-select is simple, just hold command key and drag-and-drop or double click will do the trick. We will have some discrete highlight text, something like this:
i.e. I can have "At work" & "inversel" highlight at the same time.
But this does not work in tmux session with iterm2, hold command key and drag-and-drop will not select anything or highlight.
Thanks for any suggestions.
EDIT:
A million thanks to #Simba for the detailed explanation. But I can't find the "mouse report" switch, is this about the item2 version or I miss something?
EDIT2:
#Simba I found the box (Session -> Edit Session -> Terminal -> Enable mouse reporting), but uncheck it's not working, even after I restart itemr2 it's checked again everytime LOL
EDIT3:
After several times restart now it's working, I have no idea what's happening... Thanks! #Simba
"hold command key and drag-and-drop" to do multiple copy is a feature of iTerm2, the terminal. Within tmux, the copy action is handled by tmux, and tmux doesn't support this multi-copy feature.
Method 1
An alternative way: use tmux integration mode of iTerm2 by starting a tmux session with tmux -CC.
After this, the drag action is detected by iTerm2 directly. You can copy the content in iTerm2 by holding "Command" just as when tmux is not used.
Method 2
Cmd + Drag is bound to continuous selection in iTerm2. Since "mouse reporting" is intercepted by tmux, to use this feature (continuous selection), you need to disable "mouse reporting" temporarily.
Uncheck "Session -> Terminal State -> Mouse reporting".
Do continuous selection with Cmd + Drag.
Enable "Mouse reporting" to make tmux work properly.
Drawback: To use continuous selection, "Mouse reporting" must be disabled. But once "mouse reporting" is disabled, you can't scroll to previous or next page. That means you can do continuous selection in current page.
Quote from iTerm2 FAQ
Q: What modifier keys affect marking a selection for copy and paste?
A: If you hold down modifier keys while making a selection, the behavior changes in various ways:
Alt/Option: Mouse reporting will be disabled. If you're using vim and you can't make a selection, try holding down the alt key and see if that fixes it.
Alt + Cmd: Make a rectangular selection.
Shift: Extend an existing selection.
Alt + Shift: Extend a rectangular selection.
Cmd: Make a discontinuous selection
Unfortunately, selection modifier key Alt + Cmd is bound to " rectangular selection" and it doesn't seem to be customizable. But you can bind a shortcut to toggle "mouse reporting".
The default key binding for switching to previous buffer in Vim is CTRL-6 but this does not work from within tmux.
My tmux prefix is CTRL-a if that is relevant.
There are 2 key mappings for editing alternate file. CTRL-6 and CTRL-^
Try pressing Ctrl+Shift+6(which is CTRL-^)
I want to create a tmux keybind which sends a set of keystrokes to the marked pane. This is convenient for implementing a hotkey that runs something so I don't have to manually focus another pane and then come back.
But I'd like for this key to not do anything if there's no marked pane present. I've looked in the manpage and found nothing obvious that I can use to check this state.
To target the marked pane you can use -t '~' or -t '{marked}'.
In this case it is simply a matter of send -t '~' <keys here>.
A more generic way to get the marked pane in your shell would be tmux display -p -t '~' '#D'.
When switching panes in tmux using ^B and cursor keys, what is the quickest way to get out of pane-switching mode and return input handling to the program in the pane?
For instance, you just switched to the shell in your left pane with ^B and Left, and now you want to press Up and Enter to repeat the shell's last command, except tmux steals the Up keypress thinking you're still switching panes.
There has to be a key combo or something to finish pane switching, right?
because pressing arrows is "expensive" keystroke with my keyboard, I hardly use arrow keys.
My vim has ctrl-h,j,kl to switch windows, so I defined in tmux prefix h,j,k,l to switch panes. (my prefix is ctrl-a)
For commandline editing, I don't use any arrow keys either, instead, I use ctrl/alt heavily, my ctrl key is at a good position to press. so re-run last command, I press ctrl-p, enter.
Using ctrl/alt to edit commandline is fast and convenient, since you don't leave your home row.
ctrl-p last cmd
ctrl-h backspace
ctrl-a first col
ctrl-d del current char
ctrl-e eol
ctrl-w remove word backwards
ctrl-b/f back/forward
alt-b/f back/forward a word
alt-d remove word forward
there are a lot more... like ctrl-k, ctrl-u, ctrl-y, alt-. etc.
And if I need edit a really long and complex command, I do ctrl-x ctrl-e, and edit it in my vim.