FAQ 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. tmux frequently asked questions
  2. ******************************************************************************
  3. * PLEASE NOTE: most display problems are due to incorrect TERM! Before *
  4. * reporting problems make SURE that TERM settings are correct inside and *
  5. * outside tmux. *
  6. * *
  7. * Inside tmux TERM must be "screen" or similar (such as "screen-256color"). *
  8. * Don't bother reporting problems where it isn't! *
  9. * *
  10. * Outside, it must match your terminal: particularly, use "rxvt" for rxvt *
  11. * and derivatives. *
  12. ******************************************************************************
  13. * How is tmux different from GNU screen?
  14. tmux and GNU screen have many similarities. Some of the main differences I am
  15. aware of are (bearing in mind I haven't used screen for a few years now):
  16. - tmux uses a client-server model. Each server has single Unix domain socket in
  17. /tmp and within one server there are multiple sessions which may be attached
  18. to multiple clients (terminals).
  19. This has advantages, notably: windows may be linked simultaneously to
  20. multiple sessions; windows may be moved freely between sessions; and a client
  21. may be switched between sessions easily (C-b D). There is one major
  22. disadvantage: if the server crashes, game over, all sessions die. In
  23. practice, however, tmux is quite stable and gets more so as people report any
  24. bugs they hit :-).
  25. This model is different from screen, where typically each new screen instance
  26. is independent. tmux supports the same behaviour by using multiple servers
  27. with the -L option but it is not typically recommended.
  28. - Different command interfaces. One of the goals of tmux is that the shell
  29. should be easily usable as a scripting language - almost all tmux commands
  30. can be used from the shell and behave identically whether used from the
  31. shell, from a key binding or from the command prompt. Personally I also find
  32. tmux's command interface much more consistent and clearer, but this is
  33. subjective.
  34. - tmux calls window names (what you see in the status line) "names", screen
  35. calls them "titles".
  36. - tmux has a multiple paste buffers. Not a major one but comes in handy quite a
  37. lot.
  38. - tmux supports automatically renaming windows to the running application
  39. without gross hacks using escape sequences. Its even on by default.
  40. - tmux has a choice of vi or emacs key layouts. Again, not major, but I use
  41. emacs so if tmux did support only one key set it would be emacs and then all
  42. the vi users would get humpy. Key bindings may be completely reconfigured in
  43. any case.
  44. - tmux has an option to limit the window size.
  45. - tmux has search in windows (C-b f).
  46. - The window split (pane) model is different. tmux has two objects, windows and
  47. panes; screen has just windows. This difference has several implications:
  48. * In screen you can have a window appear in several layouts, in tmux a pane
  49. can only be in one window (fixing this is a big todo item but quite
  50. invasive).
  51. * tmux layouts are immutable and do not get changed unless you modify them.
  52. * In tmux, all panes are closed when you kill a window.
  53. * tmux panes do not have individual names, titles and so on.
  54. I think tmux's model is much easier to manage and navigate within a window,
  55. but breaking panes off from and joining them to windows is more clumsy.
  56. tmux also has support for preset pane layouts.
  57. - tmux's status line syntax is more readable and easier to use. I think it'd be
  58. hard for anyone to argue with this. tmux doesn't support running a command
  59. constantly and always using the last line of its output, commands must be run
  60. again each time.
  61. - tmux has modern, easily extended code. Again hard to argue screen is better
  62. if you have looked at the code.
  63. - tmux depends on libevent. I don't see this as a disadvantage: libevent is
  64. small and portable, and on modern systems with current package management
  65. systems dependencies are not an issue. libevent brings advantages in code
  66. simplicity and performance.
  67. - screen allows the window to be bigger than the terminal and can pan around
  68. it. tmux limits the size to the largest attached client. This is a big todo
  69. item for tmux but it is not trivial.
  70. - screen has builtin serial and telnet support; this is bloat and is unlikely
  71. to be added to tmux.
  72. - Environment handling is different.
  73. - tmux tends to be more demanding on the terminal so tends to show up terminal
  74. and application bugs which screen does not.
  75. - screen has wider platform support, for example IRIX, and for odd terminals.
  76. * I found a bug! What do I do?
  77. Check the latest version of tmux from Git to see if the problem is still
  78. reproducible. Sometimes the length of time between releases means a lot of
  79. fixes can be sitting in Git and the problem might already be fixed.
  80. Please send bug reports by email to nicholas.marriott@gmail.com or
  81. tmux-users@googlegroups.com. Please include as much of the following
  82. information as possible:
  83. - the version of tmux you are running;
  84. - the operating system you are using and its version;
  85. - the terminal emulator you are using and the TERM setting when tmux was
  86. started;
  87. - a description of the problem;
  88. - if the problem is repeatable, the steps to repeat the problem;
  89. - for screen corruption issues, a screenshot and the output of "infocmp $TERM"
  90. from outside tmux are often very useful.
  91. * Why doesn't tmux do $x?
  92. Please send feature requests by email to tmux-users@googlegroups.com.
  93. * Why do you use the screen terminal description inside tmux? It sucks.
  94. It is already widely available. It is planned to change to something else such
  95. as xterm-xfree86 at some point, if possible.
  96. * I don't see any colour in my terminal! Help!
  97. On some platforms, common terminal descriptions such as xterm do not include
  98. colour. screen ignores this, tmux does not. If the terminal emulator in use
  99. supports colour, use a value for TERM which correctly lists this, such as
  100. xterm-color.
  101. * tmux freezes my terminal when I attach to a session. I even have to kill -9
  102. the shell it was started from to recover!
  103. Some consoles really really don't like attempts to set the window title. Tell
  104. tmux not to do this by turning off the "set-titles" option (you can do this
  105. in .tmux.conf):
  106. set -g set-titles off
  107. If this doesn't fix it, send a bug report.
  108. * Why is C-b the prefix key? How do I change it?
  109. The default key is C-b because the prototype of tmux was originally developed
  110. inside screen and C-b was chosen not to clash with the screen meta key. It
  111. also has the advantage of not interfering with the use of C-a for start-of-line
  112. in emacs and the shell (although it does interfere with previous-character).
  113. Changing is simple: change the "prefix-key" option, and - if required - move
  114. the binding of the "send-prefix" command from C-b (C-b C-b sends C-b by
  115. default) to the new key. For example:
  116. set -g prefix C-a
  117. unbind C-b
  118. bind C-a send-prefix
  119. * How do I use UTF-8?
  120. When running tmux in a UTF-8 capable terminal, UTF-8 must be turned on in tmux;
  121. as of release 0.9, tmux attempts to autodetect a UTF-8-capable terminal by
  122. checking the LC_ALL, LC_CTYPE and LANG environment variables. list-clients may
  123. be used to check if this is detected correctly; if not, the -u command-line
  124. flag may be specified when creating or attaching a client to a tmux session:
  125. $ tmux -u new
  126. Since the 1.0 release, tmux will turn on UTF-8 related options automatically
  127. (ie status-utf8, and utf8) if the above conditions are met.
  128. * How do I use a 256 colour terminal?
  129. Provided the underlying terminal supports 256 colours, it is usually sufficient
  130. to add the following to ~/.tmux.conf:
  131. set -g default-terminal "screen-256color"
  132. Note that some platforms do not support "screen-256color" ("infocmp
  133. screen-256color" will return an error) - in this case see the next entry in
  134. this FAQ.
  135. tmux attempts to detect a 256 colour terminal both by looking at the colors
  136. terminfo entry and by looking for the string "256col" in the TERM environment
  137. variable.
  138. If both these methods fail, the -2 flag may be passed to tmux when attaching
  139. to a session to indicate the terminal supports 256 colours.
  140. * vim or $otherprogram doesn't display 256 colours. What's up?
  141. Some programs attempt to detect the number of colours a terminal is capable of
  142. by checking the colors terminfo or Co termcap entry. However, this is not
  143. reliable, and in any case is missing from the "screen" terminal description
  144. used inside tmux.
  145. There are two options (aside from using "screen-256color") to allow programs to
  146. recognise they are running on a 256-colour terminal inside tmux:
  147. - Manually force the application to use 256 colours always or if TERM is set to
  148. screen. For vim, you can do this by overriding the t_Co option, see
  149. http://vim.wikia.com/wiki/256_colors_in_vim.
  150. - Creating a custom terminfo file that includes colors#256 in ~/.terminfo and
  151. using it instead. These may be compiled with tic(1).
  152. * How do I make Ctrl-PgUp and Ctrl-PgDn work in vim?
  153. tmux supports passing through ctrl (and where supported by the client terminal,
  154. alt and shift) modifiers to function keys using xterm(1)-style key sequences.
  155. This may be enabled per window, or globally with the tmux command:
  156. setw -g xterm-keys on
  157. Because the TERM variable inside tmux must be set to "screen", vim will not
  158. automatically detect these keys are available; however, the appropriate key
  159. sequences can be overridden in .vimrc using the following:
  160. if &term == "screen"
  161. set t_kN=^[[6;*~
  162. set t_kP=^[[5;*~
  163. endif
  164. And similarly for any other keys for which modifiers are desired.
  165. Please note that the "xterm-keys" setting may affect other programs, in the
  166. same way as running them in a standard xterm; for example most shells do not
  167. expect to receive xterm(1)-style key sequences so this setting may prevent keys
  168. such as ctrl-left and ctrl-right working correctly. tmux also passes through
  169. the ctrl (bit 5 set, for example ^[[5~ to ^[[5^) modifier in non-xterm(1) mode;
  170. it may be possible to configure vim to accept these, an example of how to do so
  171. would be welcome.
  172. vim users may also want to set the "ttyfast" option inside tmux.
  173. * How do I make ctrl and shift arrow keys work in emacs?
  174. The terminal-init-screen function in term/screen.el is called for new frames,
  175. but it doesn't configure any function keys.
  176. If the tmux xterm-keys option is on, it is enough to define the same keys as
  177. xterm. Add the following to init.el or .emacs to do this:
  178. (defadvice terminal-init-screen
  179. ;; The advice is named `tmux', and is run before `terminal-init-screen' runs.
  180. (before tmux activate)
  181. ;; Docstring. This describes the advice and is made available inside emacs;
  182. ;; for example when doing C-h f terminal-init-screen RET
  183. "Apply xterm keymap, allowing use of keys passed through tmux."
  184. ;; This is the elisp code that is run before `terminal-init-screen'.
  185. (if (getenv "TMUX")
  186. (let ((map (copy-keymap xterm-function-map)))
  187. (set-keymap-parent map (keymap-parent input-decode-map))
  188. (set-keymap-parent input-decode-map map))))
  189. And ensure .tmux.conf contains "set -g xterm-keys on".
  190. Alternatively, the screen.el file can be copied to the load path and
  191. customized.
  192. * Why doesn't elinks set the window title inside tmux?
  193. There isn't a way to detect if a terminal supports setting the window title, so
  194. elinks attempts to guess by looking at the environment. Rather than looking for
  195. TERM=screen, it uses the STY variable to detect if it is running in screen;
  196. tmux does not use this so the check fails. A workaround is to set STY before
  197. running elinks.
  198. The following shell function does this, and also clears the window title on
  199. exit (elinks, for some strange reason, sets it to the value of TERM):
  200. elinks() {
  201. STY= `which elinks` $*
  202. echo -ne \\033]0\;\\007;
  203. }
  204. * What is the proper way to escape characters with #(command)?
  205. When using the #(command) construction to include the output from a command in
  206. the status line, the command will be parsed twice. First, when it's read by the
  207. configuration file or the command-prompt parser, and second when the status
  208. line is being drawn and the command is passed to the shell. For example, to
  209. echo the string "(test)" to the status line, either single or double quotes
  210. could be used:
  211. set -g status-right "#(echo \\\\(test\\\\))"
  212. set -g status-right '#(echo \\\(test\\\))'
  213. In both cases, the status-right option will be set to the string "#(echo
  214. \\(test\\))" and the command executed will be "echo \(test\)".
  215. * tmux uses too much CPU. What do I do?
  216. Automatic window renaming may use a lot of CPU, particularly on slow computers:
  217. if this is a problem, turn it off with "setw -g automatic-rename off". If this
  218. doesn't fix it, please report the problem.
  219. * I use PuTTY and my tmux window pane separators are all qqqqqqqqq's!
  220. PuTTY is using a character set translation that doesn't support ACS line
  221. drawing. With a Unicode font, try setting PuTTY to use a different translation
  222. on the Window -> Translation configuration page. For example, change UTF-8 to
  223. ISO-8859-1 or CP437. It may also be necessary to adjust the way PuTTY treats
  224. line drawing characters in the lower part of the same configuration page.
  225. * What is the best way to display the load average? Why no #L?
  226. It isn't possible to get the load average portably in code and it is preferable
  227. not to add portability goop. The following works on at least Linux, *BSD and OS
  228. X:
  229. uptime|awk '{split(substr($0, index($0, "load")), a, ":"); print a[2]}'
  230. * How do I attach the same session to multiple clients but with a different
  231. current window, like screen -x?
  232. One or more of the windows can be linked into multiple sessions manually with
  233. link-window, or a grouped session with all the windows can be created with
  234. new-session -t.
  235. * Ctrl and arrow keys doesn't work in putty! What do I do?
  236. putty inverts the sense of the cursor key mode on ctrl, which is a bit hard for
  237. tmux to detect properly. To get ctrl keys right, change the terminfo settings
  238. so kUP5 (Ctrl-Up etc) are the adjusted versions, and disable smkx/rmkx so tmux
  239. doesn't change the mode. For example with this line in .tmux.conf (assuming you
  240. have TERM set to xterm):
  241. set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"
  242. Note that this will only work in tmux 1.2 and above.
  243. * How can I blank the tmux window?
  244. GNU screen has a feature whereby it will blank the screen after a period of
  245. inactivity. To do the same thing in tmux, use the lock-command setting, for
  246. example (with GNU bash):
  247. set -g lock-command 'tput civis && read -s -n1'
  248. This will remove the cursor and tell the shell to quit once a key has been
  249. pressed. For zsh, use "read -s -k1".
  250. In addition, it's possible to have both blanking and locking (for instance via
  251. lock(1) or vlock(1)) by using the following:
  252. bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
  253. * I don't see italics! Or less and vim show italics and reverse the wrong way round!
  254. GNU screen does not support italics and the "screen" terminfo description uses
  255. the italics escape sequence incorrectly.
  256. As of tmux 2.1, if default-terminal is set to "screen" or matches "screen-*",
  257. tmux will behave like screen and italics will be disabled.
  258. To enable italics, create a new terminfo entry called "tmux" (some platforms
  259. may already have this, you can check with "infocmp tmux"):
  260. $ cat <<EOF|tic -x -
  261. tmux|tmux terminal multiplexer,
  262. ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@,
  263. use=xterm+tmux, use=screen,
  264. tmux-256color|tmux with 256 colors,
  265. use=xterm+256setaf, use=tmux,
  266. EOF
  267. $
  268. And tell tmux to use it in ~/.tmux.conf:
  269. set -g default-terminal "tmux"
  270. If using urxvt, make sure you have an italics capable font enabled. for
  271. example, add to ~/.Xdefaults:
  272. urxvt.italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true
  273. * How can I make tmux use my terminal's scrollback buffer?
  274. Normally, tmux enables the terminal's "alternate screen". Most terminals (such
  275. as xterm) do not save scrollback for the alternate screen. You might prefer
  276. tmux to use the normal screen, so it uses your terminal's scrollback
  277. buffer. This way, you can access the scrollback buffer as usual, for example
  278. using the mouse wheel - although there is no guarantee output inside tmux will
  279. always (or ever) be added to the scrollback.
  280. You can make tmux use the normal screen by telling it that your terminal does
  281. not have an alternate screen. Put the following in ~/.tmux.conf:
  282. set -ga terminal-overrides ',xterm*:smcup@:rmcup@'
  283. Adjust if your $TERM does not start with xterm.
  284. tmux will still emulate the alternate screen for applications run under tmux,
  285. so you don't really lose anything with this setting. The only disadvantage is
  286. that when you exit tmux, it will not restore whatever was there before you
  287. started.
  288. * How do I see the default configuration?
  289. Show the default session options by starting a new tmux server with no
  290. configuration file:
  291. $ tmux -Lfoo -f/dev/null start\; show -g
  292. Or the default window options:
  293. $ tmux -Lfoo -f/dev/null start\; show -gw
  294. * How do I copy a selection from tmux to the system's clipboard?
  295. When running in xterm(1), tmux can automatically send copied text to the
  296. clipboard. This is controlled by the set-clipboard option and also needs this
  297. X resource to be set:
  298. XTerm*disallowedWindowOps: 20,21,SetXprop
  299. For rxvt-unicode (urxvt), there is an unofficial Perl extension here:
  300. http://anti.teamidiot.de/static/nei/*/Code/urxvt/
  301. Otherwise a key binding for copy mode using xclip (or xsel) works:
  302. bind -temacs-copy C-y copy-pipe "xclip -i >/dev/null"
  303. Or for inside and outside copy mode with the prefix key:
  304. bind C-y run -b "tmux save-buffer - | xclip -i"
  305. On OS X, reattach-to-usernamespace lets pbcopy/pbpaste work:
  306. https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
  307. * Why do I see dots around a session when I attach to it?
  308. tmux limits the size of the window to the smallest attached session. If
  309. it didn't do this then it would be impossible to see the entire window.
  310. The dots mark the size of the window tmux can display.
  311. To avoid this, detach all other clients when attaching:
  312. $ tmux attach -d
  313. Or from inside tmux by detaching individual clients with C-b D or all
  314. using:
  315. C-b : attach -d