5 ms·
Best thing I ever did for tmux was change the command key prefix to "C-\". With caps lock mapped to control, this makes tmux commands available with almost no h
by sls 9y ago
Best thing I ever did for tmux was change the command key prefix to "C-\". With caps lock mapped to control, this makes tmux commands available with almost no hand motion, just a slight reaching out with the pinkies. It also restores access to C-b for "back one character" in emacs and all programs using emacs key bindings, which is hardwired into my fingers at this point. (You're blocking emacs' function "toggle-input-method" - "Enable or disable multilingual text input method for the current buffer". For some users that would probably be an issue, but hasn't been for me.)
Another useful thing is to "bind-key C-\ last-window". That makes C-\ C-\ jump back to the last window you visited, which facilitates creating short-lived windows for specific tasks.
Final small tweak I like is "set -g base-index 1" so that C-\ 1 is the first window, 2 is the next, etc. instead of having the first window way over on 0.
My other tweaks are probably more idiosyncratic to my workflow.
- jwr 9y agoGood heavens, how do you send SIGQUIT to your programs then?
- c256 9y agoGiven that the context means that there’s always a shell available, presumably ‘with kill -QUIT’. I got into this habit myself many years ago, when varied access methods made it uncomfortable to rely on having a full range of key-bindings.
- sls 9y agoAs c256 surmised, I use kill to send signals other than SIGKILL. I don't think I've ever even known about the C-\ or C-y bindings for SIGQUIT. I also hardly ever use shell job control, to the extent that I have an alias fg that does something unrelated, so I would need to say \fg to get the shell foreground command. But if for some reason I wanted to do that, I would use C-\ : send-prefix. That sends the prefix character to the process running in tmux, in this case the shell. It's also super useful if you ever find yourself running a nested tmux (i.e. in an ssh session) with the same prefix character. You can just send-prefix d to disconnect the remote shell from the remote tmux session, then open a new local shell outside of your local tmux session, log in and reconnect to the remote tmux.
- sjagoe 9y agoI also use C-\ as prefix, but I have additionally bound "C-\ b" to send-prefix because I do often have nested tmux sessions.
- jodrellblank 9y agoYou can just send-prefix d to disconnect the remote shell from the remote tmux session, then open a new local shell outside of your local tmux session, log in and reconnect to the remote tmux. You can open a new shell and reconnect to the remote tmux first, then use Ctrl-b, Shift-D to bring up a list of connected sessions and kick off / detach the nested original one you don't want.
- jwr 9y agoWell, I was half-joking :-) and I did expect that few people would know about C-\ for SIGQUIT. Myself, I find it very useful for programs written by people who think it's a good idea to capture SIGINT (it's not), because same people (and I will refrain from using adjectives) forget about SIGQUIT most of the time. Which means I can quickly kill a misbehaving program without typing something in a separate shell.
- zipperhead 9y agoInteresting choice. I've been using ` (backtick) for command key, which has the advantage of not requiring a control key input. I just realized though that I don't have a mapping for last-window. And there doesn't seem to be a default.
- 0xcde4c3db 9y agoDid you also get in the habit of using $(<command>) instead of `<command>` for substitution? I keep falling back into using backticks if I'm not thinking too much about it.
- yjftsjthsd-h 9y agoI almost always use that anyways, because then I can clearly see start and end (and nest them easily).
- zipperhead 9y agoYes. You might look into setting up shellcheck (https://www.shellcheck.net/ https://www.shellcheck.net/) as a linter for your editor - it'll help break your habit pretty quickly.
- wasted_intel 9y agoI use a backtick as well. Although rare, if I'm writing a Markdown doc and want to use inline pre-formatted blocks, it's a pain to work around, but otherwise, it's been great.
- zipperhead 9y agoNot sure if you are aware of this but the bind-key here sets it up so that pressing ` twice sends the backtick through: set-option -g prefix ` bind-key ` send-prefix I don't find it's too much of a pain to press twice when in markdown.
- wasted_intel 9y ago
- graywh 9y agoC-\ is an interesting choice. I use C-_, which can be "triggered" with C-7 and often with C-/.
- vhodges 9y agoI too use C-\ and largely for similar reasons!
- nandkeypull 9y agoBest thing I ever did for tmux was to get rid of the annoying command prefix altogether and just use bindings with Ctrl/Shift and the arrow keys - it's much faster, e.g. # Window switching bind -n S-up new-window bind -n S-down confirm-before -p "kill-window #W? (y/n)" kill-window bind -n S-left prev bind -n S-right next # Pane switching bind -n C-left select-pane -L bind -n C-right select-pane -R bind -n C-down select-pane -D bind -n C-up select-pane -U # Special pane operations bind -n C-M-up respawn-pane -k bind -n C-M-down kill-pane bind -n C-M-left swap-pane -U bind -n C-M-right swap-pane -D # Window splitting bind -n C-M-\ split-window -h bind -n C-M-] split-window -v
- sandGorgon 9y agoThanks ! I was looking for gnome shell style navigation
- betaby 9y agoC-M-left,right is used in some wm to cycle desktops, otherwise good idea.
- xfalcox 9y agoHave you ever heard about byobu? It's basically a tmux wrapper with crtl/shift hotkeys by default.
- MereInterest 9y agoYeah, C-b takes way too much hand stretching for common use with a single hand. I remapped mine to C-z instead. I don't miss have C-z to interrupt a program, because when using tmux, I tend to open new shells instead.
- znpy 9y ago> It also restores access to C-b for "back one character" in emacs If you run emacs as a daemon you can do pretty much everything tmux/screen do, without sacrificing precious keystrokes :P