Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Screen goes with CTRL+a. tmux, as developed within screen, uses CTRL+b. Both are also keystrokes in other editors, shells, etc. What do you suggest, which one conflictes at least with other programs?

share|improve this question

closed as primarily opinion-based by slhck Dec 4 '13 at 11:46

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

15 Answers 15

up vote 11 down vote accepted

Ctrl+A is also known to cause problems with Emacs, including Bash in Emacs mode. It sounds like this is not a problem for you.

Ctrl+O is the other option I've seen. Apparantly, this is the default in RatPoison (this is an X window manager that doesn't need a mouse). I've used Ctrl+O when using nested screens: Ctrl+O for the outer one and Ctrl+A for the inner ones. Worked well, but kinda scared my colleagues. :-)

I was just thinking and if you use vi rather than Emacs, there are a few alternatives. Ctrl+G isn't used by much, for instance.

share|improve this answer
4  
For Emacs users Ctrl+O seems to be the the best pick: In emacs it´s only "open a new line at the cursor" and in bash "repeate a command sequence". –  Flow Nov 24 '09 at 8:15
1  
+1 if you are OK with right handed ctrl-operations, this looks like a good backup. I'm a lefty myself ;-) –  DaveParillo Nov 24 '09 at 16:56
2  
I think Ctrl+O breaks vim –  Mu Qiao Mar 26 at 14:36
5  
I agree with @MuQiao. Ctrl-o is used in Vim to jump to an older cursor position (equivalent of back button in many IDEs), a feature I use very often while browsing code in Vim. Ctrl-b is synonymous to PageUp in Vim. I don't use Ctrl-b at all on Vim. So for Vim users like me, Ctrl-b is still a better choice than Ctrl-o. I use C-j as my prefix key since C-j is synonymous to j or <Down> in Vim and nobody uses C-j to move one line down in Vim. I have this in my ~/.tmux.conf: set -g prefix2 C-j; bind-key C-j send-prefix -2 –  Susam Pal Apr 10 at 9:44

I think ^\ (a.k.a. ^|) is the best if it's in a convenient position on your keyboard layout. It's uses in other programs are quite rare:

  • sending SIGQUIT to a process
  • aborting for or while loops in a shell when ^C is intercepted
  • toggle-input-method in emacs

I don't know of any other uses. Be careful to not accidentally kill a processes outside of tmux or screen after getting used to it. It happened to me only once in a few years though.

~/.tmux.conf:

unbind-key C-b
set -g prefix 'C-\'
bind-key 'C-\' send-prefix

~/.screenrc:

escape ^|^|
share|improve this answer
    
Nice one! Thanks! –  grm May 15 '12 at 17:02
    
I tried this but tmux complains about the use of C-`. Can I escape the ` character somehow? –  Jason Jul 11 '12 at 0:01
    
`set -g prefix C-\` was needed for 1.8 –  Elijah Lynn Jul 31 '13 at 17:02
1  
Just to let somebody else know, you should write 'C-\' instead of ` C-\ ` in the tmux config. –  gns-ank Feb 14 at 10:46
    
Thanks, fixed for 1.8. –  cjay Mar 6 at 21:25

For people who want to use backtick as the escape in tmux, you'll want to add:

unbind C-b
set -g prefix `
bind-key ` send-prefix

That last one is important, else you can't type a backtick for other purposes :-)

share|improve this answer
    
Backtick seems like a good idea until you paste in some SQL... –  Synchro Jan 9 '13 at 9:43
2  
@Synchro on tmux 1.8 it's not an issue anymore thanks to assume-paste-time option which is on by default (set to 1ms). See here: sourceforge.net/p/tmux/tmux-code/ci/… –  sickill Mar 27 '13 at 20:46
    
I found this question looking for alternatives to backtick as it started to cause trouble after I got used to using backticks instead of $() in shells. Also it becomes a pain once you start writing a lot of Markdown. I've been using it for several years, but unfortunately I'll have to change it now. –  kirelagin Jul 1 at 20:09
    
In .tmux.conf I also have bind-key C-a set-option -g prefix C-a. Whenever I need to use backticks I hit `-Ctrl-a which sets my prefix to C-a. And I have bind-key C-b set-option -g prefix ` so I can hit C-a-C-b to go back –  boris yesterday

I use a complex system for screen. My default escape is set to \140\140, which is backtick. The Ctrl-A complicates both Emacs and command line editting for me within Zsh, and I dislike Ctrl-O (2 hand operations for most screen actions).

I rebind 's' to screen 1 so that new sessions are created from left to right on the keyboard starting at 1. This allows me to reserve screen 0 for what I consider persistent or reference windows. It's very quick one handed gesture to (backtick)1, (backtick)2, (backtick)3 to swap between windows.

The issue with using backtick in a unix environment is when attempting to cut and paste shell/perl script code. For this reason I bindkey F11/F12 to switch between my escape character.

bindkey -d -k F1        escape ^O^O # bound to F11

bindkey -d -k F2        escape \140\140 # bound to F12

This will swap the escape to Ctrl-O for when I'm doing cut and paste operations. I've found hitting a double tick is simple, and a good trade off for most screen operations.

share|improve this answer
    
Creative solution. I'm impressed. –  staticsan Nov 25 '09 at 2:30
    
bind-key -n F11 set -g prefix ` bind-key -n F12 set -g prefix C-o Updates for tmux in case others want to adapt this. –  milkypostman Feb 10 '12 at 4:49
1  
Is there a way to set some kind of minimal timeout for prefix+other_key combo in tmux so when pasting code it doesn't trigger any command but when typing backtick+key from keyboard it does because the pause between backtick and the other key was longer? –  sickill May 5 '12 at 16:15

I use Ctrl-Q in tmux and it has worked well so far. I have to mention, though, that it conflicts with shell flow control. By default, Ctrl-Q is used to re-enable output after stopping it with Ctrl-S. Having been surprised by a stuck shell a few times after accidentally hitting Ctrl-S, I have learned not to press Ctrl-S.

(One could also turn off flow control altogether with stty -ixon, or bind different keys to stty start and stty stop.)

# tmux.conf
unbind C-b
set -g prefix C-q
share|improve this answer
    
I've adopted this bind and I find it very convenient. Thanks! –  aymericbeaumet Aug 23 '13 at 7:29
    
My favorite as well, since I always disable the terminal control flow stuff. –  Jack O'Connor Aug 24 '13 at 3:10
1  
Used in emacs for quote-inserted. Sample use (in emacs): if I want to search for the next tab character - <Ctrl-s>+<Ctrl-q>+<TAB> –  nhed Apr 8 at 17:15

I've heard of ` (backtick) being used and then you just have to type it twice for an actual backtick. Might be better for vi users who are used to the action (unless you do the Caps lock thing).

share|improve this answer
    
How can you define backtick for tmux? –  Alexandre Nizoux Feb 8 '11 at 21:16
    
Something like: unbind C-b; set -g prefix ''; bind '' send-prefix; see Darren Hall's answer above. –  bluehavana Feb 10 '11 at 0:55
    
I'm with backtick for about a year and I'll never go back to two-key/combo prefix. Give it a try. –  sickill Jan 15 '13 at 15:29

I've got CAPS-LOCK globally mapped to ESC. Then, I use M-Space (ie. CAPS-LOCK+ Space) for my prefix.

share|improve this answer
    
Very good idea, thanks for sharing. –  AhHatem Feb 2 at 13:37

As a GNU emacs, zsh, and MS Windows user, I use Control-T. (e.g. in .screenrc:)

escape "^T^T"

Yes Control-T has something bound to it, like the pull down menu in Ubuntu's aptitude, or transpose character in Emacs.

I disregarded C-o because it requires two hands for me.

share|improve this answer

A belated suggestion: ctrl-s. ctrl-s has a number of advantages:

  1. On the home row.
  2. Still close to ctrl-a (in fact, for most typers it will use the same two fingers they used for ctrl-a), so the muscle memory switch from ctrl-a to ctrl-s is trivial -- for me, it became second nature within about an hour of first trying it.
  3. Frees up ctrl-a for emacs-style "back to beginning of line" or vim-style "increment number" operations. Or hey, for running screen inside a tmux pane without needing to worry about escaping prefix characters to control the embedded screen instance. (I often do this using a local tmux with panes containing ssh sessions to remote servers, in which I run screen)
  4. Doesn't override or add escaping-requirements to any other commonly-used terminal functionality. nothing the vast majority of people use today is on ctrl-s!

Of course, the reason that nothing is on ctrl-s is that in the terminal, it traditionally is used for flow control, dating back to the days before paging tools like more and less were common. I'm sure some GUI terminal program somewhere still has that flow-control functionality enabled by default, but I haven't actually bumped into one; the gui terminal programs I've tried all seem to completely ignore it by default, which makes that convenient key combination available for more productive uses.

So if you're not actually using screen/tmux from within (for example) a raw Linux terminal, but rather from a GUI-based terminal, then I recommend giving ctrl-s a try; it's made zipping about in tmux and screen a lot more convenient for me.

share|improve this answer
1  
Ctrl-s is forward search, for when I go to far with Ctrl-r :) –  Jack O'Connor Aug 24 '13 at 3:12

Personally, b is just too far away from Ctrl for me. When I use tmux, I alway change the binding from C-b to C-a. The main conflict with C-a is select all, but I have not found this to be a problem with the programs I use tmux with.

share|improve this answer
    
indeed, i use the default (in screen, never tried tmux) and haven't yet found a need to change it. –  quack quixote Nov 24 '09 at 4:31

I like to reserve ^Space for very special/common operations because I find it to be the easiest prefix to type, but right now I'm trying it mapped as the prefix in tmux.

It leaves your fingers free to instantly jump to the command you want to type. Give it a try.

share|improve this answer
2  
That didn't last long – I'm back to ^j. ^Space is too similar to commands that I use to invoke OSX-level apps (Spotlight, QuickSilver, DTerm). –  msutherl Aug 22 '10 at 3:32
    
I use C-j too. This is what I use in my ~/.tmux.conf: set -g prefix2 C-j; bind-key C-j send-prefix -2 –  Susam Pal Apr 10 at 9:46

I think the best solution is ^C. Emacs uses ^C as a prefix key, and I find that when I need to type ^C in a shell I almost always type two anyway. :-)

unbind-key C-b
set -g prefix C-c
bind-key C-c send-prefix
share|improve this answer

I use Caps Lock, and on OSX you need to do some special stuff to get it to work.

https://gist.github.com/burtlo/3788048

share|improve this answer

You can use backtick. Some older versions of tmux do not support backtick, so you can do the following to workaround (that would add C-`, C-@ and C-space as your meta at the same time though):

# meta prefix - @ - backtick
unbind C-b
set -g prefix C-@
bind C-@ send-prefix
bind C-@ last-window

I normally remap my CapsLock to Ctrl, so it makes even more sense with the backtick.

share|improve this answer
    
I use this as well. C-Space is quite easy to type. –  kzh Aug 21 at 16:56
    
The backtick is pretty good. However its not terminal friendly as it turns out. You definitely cannot go wrong with xterm on linux, but terminals like putty and iTerm2 (macos) have issues emulating it properly. Luckily in iTerm2 you can workaround it in the configuration. I don't use windows/putty a lot, so ctrl-space seems to be a feasible workaround. :) –  Alex Aug 23 at 19:02

I like the suggestion of binding ctrl-\ as the prefix, but in order to get this to work on Linux Mint 12, I had to escape the place the binding at the bottom. Otherwise, it wouldn't take. See my .tmux.conf here: Using tmux with both emacs and vim

share|improve this answer
    
Please don't refer to answers as "above" and "below" as the order could change. Link the answer instead. Thanks for your answer :) –  Flow Feb 4 '12 at 9:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.