Latest .tmux.conf configs

#############################
# Quick Download Cheatsheet #
#############################

### Newer Tmux Control-b Prefix ###

wget http://www.infotinks.com/tmux/home-dot-tmux-b-def-20220927.conf -O ~/.tmux.conf

curl http://www.infotinks.com/tmux/home-dot-tmux-b-def-20220927.conf -o ~/.tmux.conf

### Older Tmux Control-b Prefix ###

wget http://www.infotinks.com/tmux/home-dot-tmux-b-def-20230122-tmux18.conf -O ~/.tmux.conf

curl http://www.infotinks.com/tmux/home-dot-tmux-b-def-20230122-tmux18.conf -o ~/.tmux.conf

### New Tmux Control-a Prefix ###

wget http://www.infotinks.com/tmux/home-dot-tmux-a-fav-20220927.conf -O ~/.tmux.conf

curl http://www.infotinks.com/tmux/home-dot-tmux-a-fav-20220927.conf -o ~/.tmux.conf

### New Tmux Control-q Prefix ###

wget http://www.infotinks.com/tmux/home-dot-tmux-q-fav-20220927.conf -O ~/.tmux.conf

curl http://www.infotinks.com/tmux/home-dot-tmux-q-fav-20220927.conf -o ~/.tmux.conf

UPDATE 2023-08-28: added Prefix+R to respawn current pane with “:respawn-pane -k”. This is a useful trick if there is a stuck or frozen ssh session in a pane. Doing SSH ESCAPE KEY is semi-risky because it can quit your parent SSH session (the one your tmux is using), of course, thats not a big deal as you just reconnect and reattach to the tmux session; so in this case doing “respawn-pane -k” is the better way to go. Sidenote: I did not update the filenames because then I would have to relink all of my tmux config download links and that’s time consuming. So going forward I will stick with home-dot-tmux-<PREFIX>-<fav|def>-20220927.conf.

UPDATE 2023-01-22: Here is the default key bindings config (prefix “b” with default keys) for older tmux 1.8. Its based of the default prefix “b” key binding config file, but with some lines commented out and some uncommented. This is useful on servers that are already installed with an older tmux.

UPDATE 2022-10-21: read on my gripe with shells not fully support tmux mouse mode

UPDATE 2022-09-29: 

  • Added option to disable and enable panes. Useful for sync panes. If you have a tab / window open with a few panes and you run a sync command, it will input into all panes. With this feature you can disable some panes (first select pane and then press Prefix+Control-d to disable pane). Als you can re-enable the pane (Prefix+Control-e)

UPDATE 2022-09-09: 

  • Created new key mappings with ^q prefix instead of ^a. Noted that Control-q is not really used in bash, and this way the common shortcut Control-A is free to bash (which gets you to the front of a command)

UPDATE 2022-05-26:

UPDATE 2020-11-10:

  • New tmux config (prefix “a” w/ screen type keys). Scrolling is more percise (1 line per scroll action). Also preserve current path when creating new pane or window. UPDATE on 2022-02-28: this had errors with tmux 1.8 but works with tmux 2.8.

UPDATE 2019-07-31:

  • Tmux + clipboard works well with Windows on Cygwin:
    • you just need to use zoom (prefix key + z) and then select with Shift+Mouse Drag and it will put it into clipboard. zoom out with same key combo.
  • Tmux + clipboard works okay with MAC on Terminal:
    • you just need to use zoom (prefix key + z) and then select with Fn+Mouse Drag and it will put it into clipboard with Cmd+c; paste with Cmd+v. zoom out with same key combo.
  • By far the best though, is Tmux + clipboard on MAC with iTerm2:
    • you just need to use zoom (prefix key + z) and then select with Opt+Mouse Drag, it will auto put into clipboard. zoom out with same key combo.
    • Additionally, you can enable tmux’s clipboard to work with MAC clipboard: iterm2->Preferences->General->Enable Applications in terminal may access clipboard. Now you don’t need to zoom in, simply do a mouse drag to select and it will put selected text into clipboard. It even adheres to your pane and window dimensions

UPDATE 2019-07-26: On MAC and probably works with Linux as well, use config from 2016-10-27 or 2019-02-26 update. Then instead of Shift Key, use FN on terminal, or Option key on iterm. Articles: Keys on Mac, Copy + Paste.

UPDATE 2019-02-26: tmux that I use on work linux server (Centos 6.2 kernel 2.6.32-220). It uses some tmux plugins. Google tmux plugin manager (tpm): http://www.infotinks.com/tmux/home-dot-tmux-1.conf – I use screen like key bindings, here are the keys: screen tmux bindings

UPDATE 2016-10-27: I have installed the plugin manager for tmux which enabled mouse support in its windows and panes. Please check out the configuration file here: http://www.infotinks.com/tmux/home-dot-tmux.conf – I use screen like key bindings, here are the keys: screen tmux bindings


Command shortcut for tmux:

tmux ls instead of tmux list-sessions to list the sessions and their IDs (which will be the first number on each line, each line has a session). if detach from tmux, you reattach using the session ID you see here. They are listed at the very left output.

tmux a -t0  instead of tmux attach-session -t0  to attach to session with ID 0.

My Favorite Setup Summed up (Summary I guess)

Here is my favorite setup so that I dont have to read through all of this. To get what I want. This will be helpful for you all to if you already know what tmux is and how to use it.

# download and install tmux
apt-get update
apt-get install tmux
# option 2 of recommended key changes (control-b changes to control-a and many more changes - to match that of screen)
cp /usr/share/doc/tmux/examples/screen-keys.conf ~/.tmux.conf
# The keybindings table which apply here are at the very bottom

To start tmux just type : tmux

Here is a quick link to the bottom of the page with the SCREEN TMUX KEYBINDING:  screen tmux bindings

Quick Note To Remember if you read over everything:

Key thing to remember: check list of command man tmux or tmux list-commands and check current key bindings and all key commands inside tmux with control-b ? so thats control-b then shift-/ (or if your using control-a instead of control-b for your binding key, like how screen’s/byobu’s default keybindings are – see changing tmux key bindings option1 and option2, both covered options bring up help the same way – even though some other keys are different – so to bring up help with those methods you do control-a ? so thats control-a then shift-/ )

Main article starts now:

Tmux is a different program then screen. Some people compare byobu to tmux, but that’s incorrect (although technically okay as they seem to do the same thing, except tmux does it better). It all starts with a program called dtach, that allows to run a session under a process called init (so that if you close your putty screen, or detach from dtach- control \, then your programs still run). Then screen came out which gave you split screens and config files etc. Then byobu built upon screen, its just screen + a screen config modifier (that’s all byobu is, plus some helper programs), byubo can be set to launch on boot (but so can dtach and tmux and screen). Then you have tmux, which took from screen (and its 25+ years of code) and corrected its mistakes (screen is too slow to be updated)… So whats wrong with screen and thus dtach? Well reattaching to a session all of your regions (panes in tmux terms) are lost.

This character put in good terms (from forum: http://superuser.com/questions/423310/byobu-versus-gnu-screen-versus-tmux) :

“From an actual use case, the biggest difference between screen and tmux is how they handle split windows.

 A window in screen is a single pseudo-terminal. When attached to a screen session, you can split your terminal into multiple regions, each of which can display a screen window. Multiple regions can display the same window. The splits are not part of the session; if you detach, your splits are gone.

A window in tmux consists of one or more pseudo-terminals, one per pane. This means that panes persist if you detach and reattach later. It also means that you can display only one window at a time intmux, and that panes cannot be shared among multiple windows. tmux does allow a window to be shared among multiple sessions, however.

 I prefer the model used by tmux, but I couldn’t argue that it is better than the model used by screen.”

Also if you follow above link you will get more info about history of screen, byobu and tmux from the writer himself. In fact his next version of byobu will use tmux (I don’t know why though, tmux seems complete enough… maybe he will reintroduce its Control-a bind key back as default option)

Tmux How To

To get tmux:

# apt-get update
# apt-get install tmux

Tmux opens a session (which has window and one giant pane). A window is a tab in tmux. A pane is the region where you do commands. A pane is actually just a pseudoterminal, a ptty if you will, so it will hold the bash session (more on that later when we look indepth on how tmux looks like from a process point of view). So at first tmux is as big as putty (aside from the green footer of info)

A good idea of the window, session, pane is shown here on Daniel Miesslers site and tmux primer article (have a read its great – and what got me started on tmux): http://www.danielmiessler.com/study/tmux/

Can split window to make more panes. One window can have many panes or 1 pane

A session can have many windows (tabs) and many panes per window

Also tmux remains running on the system until the last session is exited.

 # tmux

That puts me into 1 pane, in the main window, in the current and only session. These are some basic command:

The bind Key is control-b (unlike screen control-a and byobu control-a)

Meta is ESC. So if asks to hit META-UP. Then first do Control-b then ESC-UP. Meta sometimes seen as ^.

BELOW ARE THE DEFAULT TMUX KEY BINDINGS

These are the keybindings for config file “tmux-b-def” in name.

* Control-b ? - Shows help in pane, can scroll with up and down, and quit from help with q
* Control-b " - horizontal split and jumps into it and makes bash run
* Control-b % - (control-b shift-5) vertical split and jumps into it and makes bash run
* control-b q - number each pane, show numbers on the screen telling you what number each pane is
* Control-b o - next pane
* Control-b c - create a new window/tab and bash into it
* Control-b n - next window/tab
* Control-b p - previous window/tab
* control-b NUMBER - switches to that window number (can get number from footer of tmux) (NUMBER above keys, not numpad)
* Control-b SPACE - next layout
* Control-b { - (control-b shift-[) move pane up in current window (other panes in way switch places)
* Control-b } - (control-b shift-]) move pane down in current window (other panes in way switch places)
* Control-b t - shows time in pane  (press enter or q to make it go away)
* Control-b d - detach the session, and go back to none tmux. Session & its windows & panes will continue running commands (doesnt ask to confirm)
* Control-b x - this is to exit out of the session (this will close all panes/pttys in the session), this asks for "y" to confirm so hit "y" and enter
* Control-b k - kills current window (and all of its panes/pttys), this asks for "y" to confirm so hit "y" and enter
* Control-b ARROWKEYS - move to different pane
* Control-b Esc-ARROWKEYS - enlarge or compress current pane into the direction of arrow key
* Control-b then PAGEUP/PAGEDOWN - look thru history of current pane (scroll up and down), dont hold control-b just hit it once, then pageup/down to scroll around. q when your down.
* control-b [ - copy mode, you can copy things to a file here, however you can also scroll one line at a time. After using keybinding use ARROWKEYS to scroll cursor around (to see how to copy with copy mode, google it)
* control-b z - zoom in and out of the current pane. useful to maximize the pane to select text with mouse. you can undo the zoom by repeating the command.
* control-b , - renames the current window/tab (useful). you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. this is useful to organize your windows/tabs.
* control-b $ - renames the current session. you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. if you detach from the tmux session, you will need to use this name when attaching this tmux at a later point.

Extra in my config:
* control-b control-s - sync all panes so you can type commands in all panes at same time. press same key combo to go back to single pane typing.
* control-shift left and right arrow - move window/tabs left and right, if you don't move correctly with the tabs view tmux.conf and comment current tab shifting lines and uncomment the other ones next to it. (prefix key not required)
* control-b O - disable a pane, so it can accept no keyboard input. useful in sync mode. ex: multiple panes in a window/tab but only need to sync with a few. disable panes that you dont want to sync with. click on pane and then run the command. Think of O as 0 or nothing/disabled
* control-b I - enable a pane, so it can return to accepting input. click on pane and then run the command. Think of I as 1 or on.
* control-b R - respawn current pane & kill its process with "respawn-pane -k". this is useful if you have a stuck ssh or pane.

Back to showing tmux command line – To get out of tmux: control-b d

List sessions:

# tmux list-sessions

Attach to last session:

# tmux attach

Attach to session by name(id number, left most when listing sessions):

# tmux attach -t 3

Note: cant launch tmux from tmux (unless do magic, but don’t do it)

Note: cant move panes to diff sessions or windows.

Example: Just opened a new bash/putty shell and have not entered into tmux yet. I can make a new tmux session by typign “tmux” enter, or what I want to do is go into a current tmux session and end it:

Tmux has 2 sessions opened (each with windows and panes). Lets close tmux session with name 3

 # tmux list-sessions

0: 2 windows (created Sun Jan 26 08:38:45 2014) [115x60]

3: 2 windows (created Sun Jan 26 08:45:38 2014) [115x56]

The -t is the name the name is the first number so 0 or 3

Note you can only attach and detach and connect to sessions (not windows and not panes alone) so each session will come with its many windows and panes.

I connect to session 3 (and out of each pane – by typing “exit” and enter as many times as there are panes open in the entirety of the session, closing out of each window and on final pane/window it exits the session)

 # tmux attach -t 3
[exited]

NOTE: first I typed "tmux attach -t 3", it then attached me (taking me away from the screen where I typed the attach command) Then I "exit" out of each pane (and window) and on last pane/window it closed the session. Then you see the previous bash prompt (because after the session is closed we reverted back to our previous environment which is that bash) and the "[exit]" message meaning that the session just got closed.

Or I could of just

# tmux kill-session -t 3

List the final sessions

# tmux list-sessions
0: 2 windows (created Sun Jan 26 08:38:45 2014) [115x60]

To get all command:

# tmux list-commands<span style="background-color: #ffffff; font-family: Lato, sans-serif; font-size: 16px; line-height: 1.5;"> </span>

 At command line can use autocompletion and argument detection (like cisco firewalls)

Tmux thinks ? Is a c (it lists all commands that start with c)

# tmux ?
ambiguous command: c, could be: capture-pane, choose-buffer, choose-client, choose-session, choose-window, clear-history, clock-mode, command-prompt, confirm-before, copy-mode

To see all commands begin with l

# tmux l
ambiguous command: l, could be: last-pane, last-window, link-window, list-buffers, list-clients, list-commands, list-keys, list-panes, list-sessions, list-windows, load-buffer, lock-client, lock-server, lock-session

To see all of the tmux commands

ALL TMUX COMMAND LINE OPTIONS 

# tmux list-commands
attach-session [-dr] [-t target-session]
bind-key [-cnr] [-t key-table] key command [arguments]
break-pane [-d] [-t target-pane]
capture-pane [-b buffer-index] [-E end-line] [-S start-line] [-t target-pane]
choose-buffer [-t target-window] [template]
choose-client [-t target-window] [template]
choose-session [-t target-window] [template]
choose-window [-t target-window] [template]
clear-history [-t target-pane]
clock-mode [-t target-pane]
command-prompt [-I inputs] [-p prompts] [-t target-client] [template]
confirm-before [-p prompt] [-t target-client] command
copy-mode [-u] [-t target-pane]
delete-buffer [-b buffer-index]
detach-client [-P] [-s target-session] [-t target-client]
display-message [-p] [-c target-client] [-t target-pane] [message]
display-panes [-t target-client]
find-window [-t target-window] match-string
has-session [-t target-session]
if-shell shell-command command [command]
join-pane [-dhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]
kill-pane [-a] [-t target-pane]
kill-server
kill-session [-t target-session]
kill-window [-t target-window]
last-pane [-t target-window]
last-window [-t target-session]
link-window [-dk] [-s src-window] [-t dst-window]
list-buffers
list-clients [-F format] [-t target-session]
list-commands
list-keys [-t key-table]
list-panes [-as] [-F format] [-t target]
list-sessions [-F format]
list-windows [-a] [-F format] [-t target-session]
load-buffer [-b buffer-index] path
lock-client [-t target-client]
lock-server
lock-session [-t target-session]
move-window [-dk] [-s src-window] [-t dst-window]
new-session [-d] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]
new-window [-adk] [-n window-name] [-t target-window] [command]
next-layout [-t target-window]
next-window [-a] [-t target-session]
paste-buffer [-dr] [-s separator] [-b buffer-index] [-t target-pane]
pipe-pane [-o] [-t target-pane] [command]
previous-layout [-t target-window]
previous-window [-a] [-t target-session]
refresh-client [-S] [-t target-client]
rename-session [-t target-session] new-name
rename-window [-t target-window] new-name
resize-pane [-DLRU] [-t target-pane] [adjustment]
respawn-pane [-k] [-t target-pane] [command]
respawn-window [-k] [-t target-window] [command]
rotate-window [-DU] [-t target-window]
run-shell command
save-buffer [-a] [-b buffer-index]
select-layout [-np] [-t target-window] [layout-name]
select-pane [-lDLRU] [-t target-pane]
select-window [-lnp] [-t target-window]
send-keys [-R] [-t target-pane] key ...
send-prefix [-2] [-t target-pane]
server-info
set-buffer [-b buffer-index] data
set-environment [-gru] [-t target-session] name [value]
set-option [-agsuw] [-t target-session|target-window] option [value]
set-window-option [-agu] [-t target-window] option [value]
show-buffer [-b buffer-index]
show-environment [-g] [-t target-session]
show-messages [-t target-client]
show-options [-gsw] [-t target-session|target-window]
show-window-options [-g] [-t target-window]
source-file path
split-window [-dhvP] [-p percentage|-l size] [-t target-pane] [command]
start-server
suspend-client [-t target-client]
swap-pane [-dDU] [-s src-pane] [-t dst-pane]
swap-window [-d] [-s src-window] [-t dst-window]
switch-client [-lnpr] [-c target-client] [-t target-session]
unbind-key [-acn] [-t key-table] key
unlink-window [-k] [-t target-window]

Finally How do these panes and windows look like from a process point of view:

Process Tree of Tmux

I use the word tmux server (its the tmux process that sits closest to init/systemd that wont get affected by a shutdown of ssh/telnet/bash/console/terminal/putty) to mean the processes that houses all of the sessions (and thus windows and panes) as children – but they just look as pttys running as children to tmux server process. To turn off the tmux server you must exit out of all the panes/windows/ and finally sessions. (note closing out of all the panes, will close out of all the sessions & vice versa – look above at the difference between them)

I use the word tmux client to mean that a user behind an ssh/telnet/bash/console/terminal/putty (whatever) just attached to a ptty under the tmux server. The client will then see all of the output ment for him from that ptty, and all of the users input will be directed to that ptty.

tmux only has one process existing when its ran in the background, when your detached from all of its sessions (tmux server that holds all of the pseudoterminals, pttys – by the way a single ptty is open on the smallest tmux unit, which is a pane. So 1 pane is equal to 1 ptty). Even only 1 tmux process if you have a million panes and sessions. What holds the panes/pttys is the children of that singular tmux server process.

# ps aux | egrep tmux | grep -v grep
root 18740 0.1 0.3 27460 3112 ? Ss 08:38 0:05 tmux

When you you have lets say 5 tmux sessions running in the background they are all forked off one tmux (tmuxserver – i will call it a server)

Then lets say you decide to attach to a tmux session then you will make another tmux process (tmux client process – i will call it client- i dontknow real term). From “ps aux” point of view they look the same

Lets attach to latest tmux:

# tmux attach

Then from a tmux session or from a none tmux session lets view the tmux processes (either way they should look the same if im in or out of tmux):

# ps aux | egrep tmux | egrep -v grep
root 3128 0.0 0.1 17544 1172 pts/3 S+ 09:40 0:00 tmux #<- the tmux client
root 18740 0.1 0.3 27460 3112 ? Ss 08:38 0:06 tmux #<-- my original tmux server

So what happens when I open a new bash/putty and make a new tmux session. Well if there was no tmux running before. Then you make a tmux server and a tmux client. Then if you detach then you just leave a tmux server.

tmux client connect to sessions of a tmux server

tmux server holds the sessions, but to linux each tmux server looks like a parent to X number of bash processess (X being the number of total panes open)

Example of like 5 tmux sessions, each having like 2 windows or 3 windows, and each window having 1 to 3 panes (total of 19 pttys, or 19 panes scattered across the many windows opened across the 5 sessions):

# pstree -ap
systemd,1 #<---- systemd is just a newer system then init/sysvinit so this is my pid 1
├─sshd,1445
│ ├─sshd,2718
│ │ └─bash,2833
│ │ └─pstree,6006 -ap
│ └─sshd,17300
│ └─bash,17305
│ └─tmux,3128 #<---- tmux client, notice its under sshd (so if I close putty this client will go away, but its server session will not, so its just mirroing user input and termianl output from a specific tmux server session)
├─tmux,18740 #<---- tmux server running under systemd, so if i turn off sshd, its still running, also notice that from a process point of view there is no such thing as sessions, windows, and panes. its just listing the smallest unit of everything (the panes, the panes are the ptty, pseudoterminals). The differentiation of what ptty belongs to what sessions and window is done by tmux it self.
│ ├─bash,778
│ │ └─tail,895 -f /var/log/syslog
│ ├─bash,961
│ │ └─lsof,1432 -c tmux -r m===========%D-%T============
│ ├─bash,1536
│ │ └─watch,1831 free
│ ├─bash,1600
│ │ └─top,1868
│ ├─bash,1658
│ │ └─watch,1770 ls -lisah /var/log
│ ├─bash,3129
│ ├─bash,18741
│ │ └─watch,18880 df
│ ├─bash,18787
│ │ └─watch,18891 netstat -ntlp
│ ├─bash,18833
│ │ └─top,18879
│ ├─bash,18912
│ │ └─watch,19330 ls -lisah /var/log
│ ├─bash,18966
│ ├─bash,19044
│ ├─bash,19110
│ ├─bash,19162
│ ├─bash,19212
│ │ └─watch,19297 df -h
│ ├─bash,24812
│ ├─bash,25565
│ │ └─man,26253 tmux
│ │ └─pager,26264 -s
│ ├─bash,26470
│ │ └─watch,673 df
│ └─bash,26716
│ └─watch,727 netstat

TMUX keybindings change to be like that of SCREEN

Arch linux recommends this change, just change the main binding from Control-B to Control-A. Which is alot better and ergonomically easier to use. I will call that option1.

However I propose, and the rest of the tmux community propose, lets just change the tmux key-binding to be as close to screen as possible – this also takes on option1, plus many more changes to make it as close as possible to screen bindings. I call this option 2.

Note there are other options. They are saved as other config files (you will see them, but I doubt you will use them)

Config file

Tmux when loaded from a user looks for a setting file called:

~/.tmux.conf

It also looks for /etc/tmux.conf (im not sure if it append loads or just loads one of them, if you want universal settings for everything, just put everything in /etc/tmux.conf, because the ~/.tmux.conf are per-user config files). So if you want global settings just put everything in /etc/tmux.conf, and with regards to my article mentally and physically replace ~./tmux.conf with /etc/tmux.conf

To apply the config changes, first edit or make the config file tmux.conf in etc or .tmux.conf in your users home folder then reload tmux and the new settings should take place. IF THE SETTINGS DONT TAKE IN: exit out of tmux, andkill every tmux session, an easy way to do that is killall tmux  and repeat that (but becareful not too kill it if you really need something that is running)

If its missing it loads its default tmux key bindings (so if you want to revert back to tmux keys in the future, just rename or remove .tmux.conf)

For option1 we will edit the file (use vim or something “vim ~/.tmux.conf “, press “i ” in vim to insert/type , press “ESC :wq! ” in Vim to save and exit)

For option2 we will just copy over that file (it will create it in the process)

NOTE: it seems in arch the config file might not be .tmux.conf, but might just be tmux.conf. You can search the system for it like this (xdev option to stay in the same root filesystem – so it doesnt explore other filesystems, dont -xdev use if you think your tmux.conf might be in another filesystem, like if you partitioned your home folder into a different partition – SIDENOTE: -xdev and -mount are the same thing, so either write -xdev or -mount):

# find / -xdev -type f -iname "tmux.conf"
# find / -type f -iname "tmux.conf"

Option1: Arch change: Control-b to Control-a

To take on just the key change of Control-b to Control-a and keep tmux bindings mostly the same follow the instructions in arch’s tmux article: https://wiki.archlinux.org/index.php/tmux

In ~/.tmux.conf, just put this:

# PUT THIS IN THE .tmux.conf FILE (NOTE COMMENTS ARE ALLOWED USING HASH MARK)
unbind C-b
set -g prefix C-a
bind a send-prefix

Save and exit out of your editor to save changes to ~/.tmux.conf

To take on the effect you will

Now all of the bindings are the same as I wrote above, but instead of preceding every key command with Control-b just use Control-a (its easier on the fingers). Look below for complete list

Here are the new bindings (option1 just change control-b to be control-a):

KEYBINDINGS OF TMUX SWITCHED FROM CTRL-B to CTRL-A (prefix “a”)

* Control-a " - horizontal split and jumps into it and makes bash run
* Control-a % - (control-a shift-5) vertical split and jumps into it and makes bash run
* Control-a o - next pane
* control-a q - number each pane, show numbers on the screen telling you what number each pane is
* control-a " (control-a then shift-') - window selection menu appears and you get to scroll with arrow keys to the window you want to switch to then press ENTER
* Control-a c - create new window/tab and bash into it
* Control-a n - next window/tab
* Control-a p - previous window/tab
* control-a NUMBER - switches to that window number (can get number from footer of tmux) (NUMBER above keys, not numpad)
* Control-a SPACE - next layout
* control-a then ESC then NUM - use numbers 1 thru 5 to change the layout around (There are 5 different layouts)
* Control-a { - (control-a shift-[) move pane up in current window (other panes in way switch places)
* Control-a } - (control-a shift-]) move pane down in current window (other panes in way switch places)
* Control-a t - shows time in pane (press enter or q to make it go away)
* Control-a d - detach the session, and go back to none tmux. Session & its windows & panes will continue running commands (doesnt ask to confirm)
* Control-a x - this is to exit out of the session (this will close all panes/pttys in the session), this asks for "y" to confirm so hit "y" and enter
* Control-a k - kills current window (and all of its panes/pttys), this asks for "y" to confirm so hit "y" and enter
* Control-a ARROWKEYS - move to different pane
* Control-a then Esc then ARROWKEYS - enlarge or compress current pane into the direction of arrow key
* Control-a then PAGEUP/PAGEDOWN - look thru history of current pane (scroll up and down), dont hold control-b just hit it once, then pageup/down to scroll around. q when your down.
* control-a [ - copy mode, you can copy things to a file here, however you can also scroll one line at a time. After using keybinding use ARROWKEYS to scroll cursor around (to see how to copy with copy mode, google it)
* control-a z - zoom in and out of the current pane. useful to maximize the pane to select text with mouse. you can undo the zoom by repeating the command.
* control-a , - renames the current window/tab (useful). you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. this is useful to organize your windows/tabs.
* control-a $ - renames the current session. you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. if you detach from the tmux session, you will need to use this name when attaching this tmux at a later point.


Extra in my config:
* control-a control-s - sync all panes so you can type commands in all panes at same time. press same key combo to go back to single pane typing.
* control-shift left and right arrow - move window/tabs left and right, if you don't move correctly with the tabs view tmux.conf and comment current tab shifting lines and uncomment the other ones next to it. (prefix key not required)
* control-a O - disable a pane, so it can accept no keyboard input. useful in sync mode. ex: multiple panes in a window/tab but only need to sync with a few. disable panes that you dont want to sync with. click on pane and then run the command. Think of O as 0 or nothing/disabled
* control-a I - enable a pane, so it can return to accepting input. click on pane and then run the command. Think of I as 1 or on.
* control-a R - respawn current pane & kill its process with "respawn-pane -k". this is useful if you have a stuck ssh or pane.

Option2: Change to screen bindings (Control-b to Control-a included)

Again this will change tmux keybindings to match that of screen, so for one you get the whole Control-b to Control-a change plus alot more.

First find the config file, for me they are located in (debian 7):
/usr/share/doc/tmux/examples

I notice for some other users they are in:
/usr/share/tmux/

For debian users – it all here probably:

/usr/share/doc/tmux/examples/h-boetes.conf
/usr/share/doc/tmux/examples/n-marriott.conf
/usr/share/doc/tmux/examples/screen-keys.conf
/usr/share/doc/tmux/examples/t-williams.conf
/usr/share/doc/tmux/examples/tmux.vim
/usr/share/doc/tmux/examples/vim-keys.conf

So for some people its:

/usr/share/tmux/h-boetes.conf
/usr/share/tmux/n-marriott.conf
/usr/share/tmux/screen-keys.conf
/usr/share/tmux/t-williams.conf
/usr/share/tmux/tmux.vim
/usr/share/tmux/vim-keys.conf

Long story short if your Debian user most likely your config will lie in the mentioned spot so do this:

# cp /usr/share/doc/tmux/examples/screen-keys.conf ~/.tmux.conf

If your config lies elsewhere do this:

# cp /usr/share/tmux/screen-keys.conf ~/.tmux.conf

If in tmux, changes wont take effect until you get out and get back in (sessions can still be running thats fine). If your not in tmux next time you go in tmux your changes will take on effect.

NOTE: if your config file is not in either of those places look it up like this, and make sure you have the latest version of tmux

On debian build – this will list all of the files included in your tmux install – so look where your conf files are at specifically the screen binding conf file:

# dpkg -L tmux

Note My version is:

# dpkg -l tmux
..snip..
1.6-2

None debian then just use find (one of them) to locate your tmux conf files (look for all files, that have tmux in their fullpath, and then only handpick out and show me the conf files):

# find / -type f -iwholename "*tmux*" | egrep conf
# find / -xdev -type f -iwholename "*tmux*" | egrep conf

That should output where your conf files are

NOTE ON xdev: xdev option to stay in the same root filesystem – so it doesnt explore other filesystems, dont -xdev use if you think your tmux.conf might be in another filesystem, like if you partitioned your home folder into a different partition – SIDENOTE: -xdev and -mount are the same thing, so either write -xdev or -mount

Here are the new bindings (option2, screen like settings in tmux):

NOTE: notice there really is not much difference between option1 and 2

TMUX KEYS MODIFIED TO HAVE PREFIX “a” BE SCREEN-LIKE (My Favorite/What I Use).

These apply to the tmux config files provided at the top of the article with word “fav” in the filename. There are 2 variations: ones with prefix set to “control-a” and ones set to prefix with “control-q”. In otherwords, these are the keybindings for config file “tmux-a-fav” and “tmux-q-fav” in name. For the “q” prefixed keybindings, just substitute “control-q” anywhere you see “control-a”.

* Control-a | - horizontal split and jumps into it and makes bash run
* Control-a % - (control-a shift-5) vertical split and jumps into it and makes bash run
* Control-a o - next pane
* Control-a c - create new window/tab and bash into it
* control-a q - number each pane, show numbers on the screen telling you what number each pane is
* control-a " (control-a then shift-') - window selection menu appears and you get to scroll with arrow keys to the window you want to switch to then press ENTER
* Control-a n - next window/tab
* Control-a p - previous window/tab
* control-a NUMBER - switches to that window number (can get number from footer of tmux) (NUMBER above keys, not numpad)
* control-a :next-layout ENTER - next layout (note in screen mode its not as easy as hitting the space bar after the binding key)
* control-a then ESC then NUM - use numbers 1 thru 5 to change the layout around (There are 5 different layouts)
* Control-a { - (control-a shift-[) move pane up in current window (other panes in way switch places)
* Control-a } - (control-a shift-]) move pane down in current window (other panes in way switch places)
* Control-a t - shows time in pane (press enter or q to make it go away)
* Control-a d - detach the session, and go back to none tmux. Session & its windows & panes will continue running commands (doesnt ask to confirm)
* Control-a x - this is to exit out of the session (this will close all panes/pttys in the session), this asks for "y" to confirm so hit "y" and enter
* Control-a k - kills current pane, this asks for "y" to confirm so hit "y" and enter<br />* Control-a K - kills current window/tab (and all of its panes/pttys), this asks for "y" to confirm so hit "y" and enter 
* Control-a ARROWKEYS - move to different pane
* Control-a then Esc then ARROWKEYS - enlarge or compress current pane into the direction of arrow key
* Control-a then PAGEUP/PAGEDOWN - look thru history of current pane (scroll up and down), dont hold control-b just hit it once, then pageup/down to scroll around. q when your down.
* control-a [ - copy mode, you can copy things to a file here, however you can also scroll one line at a time. After using keybinding use ARROWKEYS to scroll cursor around (to see how to copy with copy mode, google it)
* control-a z - zoom in and out of the current pane. useful to maximize the pane to select text with mouse. you can undo the zoom by repeating the command.
* control-a A - renames the current window/tab (useful). you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. this is useful to organize your windows/tabs.
* control-a $ - renames the current session. you will be prompted to rename, so use backspace to erase the current name, and type a new name and hit enter to confirm. if you detach from the tmux session, you will need to use this name when attaching this tmux at a later point.

Extra in my config:
* control-a control-s - sync all panes so you can type commands in all panes at same time. press same key combo to go back to single pane typing.
* control-shift left and right arrow - move window/tabs left and right, if you don't move correctly with the tabs view tmux.conf and comment current tab shifting lines and uncomment the other ones next to it. (prefix key not required)
* control-a O - disable a pane, so it can accept no keyboard input. useful in sync mode. ex: multiple panes in a window/tab but only need to sync with a few. disable panes that you dont want to sync with. click on pane and then run the command. Think of O as 0 or nothing/disabled
* control-a I - enable a pane, so it can return to accepting input. click on pane and then run the command. Think of I as 1 or on.
* control-a R - respawn current pane & kill its process with "respawn-pane -k". this is useful if you have a stuck ssh or pane.

BYOBU can be run with TMUX instead of SCREEN

byobu-tmux
man byobu-tmux

I just prefer good ol’ regular tmux, but thats how you have to have tmux

Install note: first installed byobu and then tmux (dont know if order matters, probably not)

apt-get install byobu
apt-get install tmux

Starting TMUX on every login

Don’t do this. Just manually run it every time. This way you have control over what session you attach to.

Check out the information here:
https://wiki.archlinux.org/index.php/tmux

One thought on “TMUX: In-depth TMUX Tutorial w/ Configs & Cheatsheets + screen, dtach, byobu

Leave a Reply

Your email address will not be published. Required fields are marked *