Table of Contents
If you want to send us your comments, please do so. Thanks
More on comments
tmux
tmux is a terminal multiplexer
Hierarchy: server - client - session - window - pane
Session names
Underscores
Underscores at the end of the session name are ignored and do not have to be entered when entering a session name. This is useful to have a nice table when doing tmux list-sessions
Even better, everything after the first underscore is ignored and does not have to be entered when the session name is used. Example: A name of a session is: host_____t5 . Command: tmux attach -t host attaches session named host_____t5
Some commands
- All commands starting with tmux must be ran in a normal terminal (not in a tmux session / window)
- In a tmux session: C-b stands for CTRL-b. All keybinding enteries need to be started with C-b unless otherwise noted
- The tmux commandline (in a tmux session / window) can be opened the the C-b : command. It has a scrollback buffer
- All commands without tmux or C-b in front of it must be ran from the tmux commandline
Command | Key-bind-ing | Explanation | Remark |
---|---|---|---|
Help commands | |||
tmux list-commands | List the commands | ||
tmux list-keys | List the default keybindings | ||
Other commands | |||
tmux list-clients | |||
tmux new-session | Start a new session. This has to be done before any other tmux command | Just tmux or tmux new can also be used | |
tmux new-session -s sessionname | Start a new session and give it a name | ||
? | List all keybindings | ||
: | Show the prompt | On the prompt line you can enter textual commands. See the “Command” column | |
$ | Change the session name | Underscores at the end of the session name are ignored and do not have to be entered when entering a session name. This is useful to have a nice table when doing tmux list-sessions | |
tmux list-sessions | s | List sessions | Q to exit the list. This command also works in an other, non tmux terminal on the same computer. tmux ls can also be used |
tmux detach-client -t /dev/pts/12 | Detach /dev/pts/12 | List with tmux list-clients | |
tmux detach-client -s sessionname | Detach a session | ||
d | Detach session | The process in the session keeps running | |
tmux attach -t sessionname | Bring a detached session in view | Underscores at the end of the session name are ignored and do not have to be entered when entering a session name. | |
tmux new-window | c | Open a new window. On the status bar two windows are now mentioned | |
w | List windows | ||
f | Find window | Execute with ENTER | |
, | Change the window name | ||
1 | Change to window 1 | Other digits change to other active windows | |
n | Change to the next window | ||
p | Change to the previous window | ||
tmux split-window -v | “ | Split the window (or pane) vertically into two panes (a horizontal line in the middle) | |
tmux split-window -h | % | Split the window (or pane) horizontally into two panes (a vertical line appears in the middle of the window) | |
tmux split-window -v -p 20 | Split the window (or pane) horizontally into two panes (a vertical line appears at 20% of the bottom of the window / pane) | ||
tmux split-window -h -p 20 | Split the window (or pane) horizontally into two panes (a vertical line appears at 20% of the right side of the window / pane) | ||
move-window -s 2 -t 4 | Move window 2 to position 4 | ||
& | Kill window | You drop out of tmux. If there are other sessions open you can get back to them by running tmux attach | |
tmux a | Attach the detached session | a can be replaced with “attach” | |
tmux a -t sessionname | Attach session sessionname | ||
break-pane | Make a window from a pane | ||
display-panes | q | Display the pane index number in all panes. As long as the pane index numbers are on the screen you can switch to an other pane by typing its number | |
tmux display-panes | q | Show pane numbers in the tmux window's panes | Add -t sessionname if there are multiple sessions of tmux running (not tested by us) |
o | Swap two panes | ||
{ | Rotates the current pane through the panes clockwise and changes place with the other pane | ||
} | Rotates the current pane through the panes anti clockwise and changes place with the other pane | ||
tmux set-option history-limit 5000 \; new-window | Set the scroll back buffer to 5000 lines. Then open a new window. Adding -g in front of history-limit makes it global | Always first set the scroll back buffer size before opening a new session, window or pane. The history-limit can also be set in .tmux.conf: set-option -g history-limit 30000. Warning: Setting a high value can consume a lot of RAM | |
space | Toggle between layouts with the number of already open panes | Warning: This destroys your current layout | |
kill-pane | x | Kills the active pane | Asks for confirmation |
C-b : kill-pane -a -t 1 | Kills all panes except for pane 1 | ||
show-messages | ~ | Show the error messages which occur briefly at the status line after issuing a command | |
display-time 5000 | Display the messages for 5 seconds on the status line. The time is in milliseconds | Time 0: display until a key is pressed | |
clock-mode -t 0 | t | Show a clock | On pane 0 |
tmux.conf
/etc/tmux.conf is the global configuration file. We had trouble with this file resulting in errors. Putting the same content in $HOME/.tmux.conf worked fine
$HOME/.tmux.conf is the user's configuration file
When the .conf files is changed the changes will probably get activated after the tmux server is restarted
The active options can be shown
- Global: tmux show-options -gw
- User only: tmux show-options -w
Some handy settings
-g means global
set -g default-terminal "screen-256color" set-option -g history-limit 50000 set-option display-time 5000 set-option display-panes-time 5000
Key bindings
Change CTRL-b to CTRL-a
unbind C-b set -g prefix C-a bind C-a send-prefix
Change CTRL-b to ALT-b (ALT is called Meta)
unbind C-b set -g prefix m-'\' bind m-'\'-b send-prefix (or is it: bind m-b ?)
Configuration settings can also be set in a script so tmux starts with all desired settings
attach detach
C-b stands for CTRL-b
- Start tmux
- Login to a remote computer with ssh
- Start tmux on the remote computer (in the tmux instance you started at point 1)
- Start a program for instance cmus (ncurses music player)
- Goto an other computer and start a terminal
- Start tmux
- Login to the same remote computer with ssh
- Do tmux attach
- Now you can also control cmus from this computer on the remote computer. The interface size is determined by the computer with the smallest screen
- You can do the same on a third computer (steps 5 -9)
- If you want to close the program make sure there are no more computers using it, then just close it. Otherwise execute the next point (12)
- If you want to free up the terminal window, want to shutdown the computer you are working on, but do not want to close the program do: C-b C-b d (detach). To reinitiate it do from the steps 5 - 9 the needed steps
- Later you can login again with ssh to the remote computer and do tmux attach to continue were you left off
Default key bindings
Sorted by Explanation
Command | Keybinding | Explanation | Remark |
---|---|---|---|
Up, Down, Left, Right | Change to the pane above, below, to the left, or to the right of the current pane | ||
M-1 to M-5 | Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled | ||
Space | Arrange the current window in the next preset layout | ||
! | Break the current pane out of the window | ||
q | Briefly display pane indexes | ||
n | Change to the next window | ||
p | Change to the previous window | ||
D | Choose a client to detach | ||
w | Choose the current window interactively | ||
= | Choose which buffer to paste interactively from a list | ||
M | Clear the marked pane | ||
c | Create a new window | ||
- | Delete the most recently copied buffer of text | ||
d | Detach the current client | ||
i | Display some information about the current window | ||
Page Up | Enter copy mode and scroll one page up | ||
[ | Enter copy mode to copy text or view the history | ||
: | Enter the tmux command prompt | ||
r | Force redraw of the attached client | ||
x | Kill the current pane | ||
& | Kill the current window | ||
? | List all key bindings | ||
# | List all paste buffers | ||
m | Mark the current pane (see select-pane -m) | ||
M-n | Move to the next window with a bell or activity marker | ||
M-p | Move to the previous window with a bell or activity marker | ||
; | Move to the previously active pane | ||
l | Move to the previously selected window | Lower case letter l (el) | |
] | Paste the most recently copied buffer of text | ||
' | Prompt for a window index to select | ||
. | Prompt for an index to move the current window | ||
f | Prompt to search for text in open windows | ||
rename-session -tcurrnenname newname | $ | Rename the current session | |
rename-window [-t target-window] new-name | , | Rename the current window | |
M-Up, M-Down, M-Left, M-Right | Resize the current pane in steps of five cells | ||
C-Up, C-Down, C-Left, C-Right | Resize the current pane in steps of one cell | ||
M-o | Rotate the panes in the current window backwards | ||
C-o | Rotate the panes in the current window forwards | ||
s | Show all windows in one window. Back to the active window with q or ENTER to go to the choosen window / pane | ||
o | Select the next pane in the current window | ||
0 to 9 | Select windows 0 to 9 | ||
C-b | Send the prefix key (C-b) through to the application | ||
~ | Show previous messages from tmux, if any | ||
t | Show the time | ||
% | Split the current pane into two, left and right | ||
“ | Split the current pane into two, top and bottom | ||
C-z | Suspend the tmux client | ||
} | Swap the current pane with the next pane | ||
{ | Swap the current pane with the previous pane | ||
L | Switch the attached client back to the last session | ||
) | Switch the attached client to the next session | ||
( | Switch the attached client to the previous session | ||
z | Toggle zoom state of the current pane |
Sorted by key
Command | Keybinding | Explanation | Remark |
---|---|---|---|
- | Delete the most recently copied buffer of text | ||
rename-window [-t target-window] new-name | , | Rename the current window | |
; | Move to the previously active pane | ||
: | Enter the tmux command prompt | ||
! | Break the current pane out of the window | ||
? | List all key bindings | ||
. | Prompt for an index to move the current window | ||
' | Prompt for a window index to select | ||
“ | Split the current pane into two, top and bottom | ||
( | Switch the attached client to the previous session | ||
) | Switch the attached client to the next session | ||
[ | Enter copy mode to copy text or view the history | ||
] | Paste the most recently copied buffer of text | ||
{ | Swap the current pane with the previous pane | ||
} | Swap the current pane with the next pane | ||
& | Kill the current window | ||
# | List all paste buffers | ||
% | Split the current pane into two, left and right | ||
= | Choose which buffer to paste interactively from a list | ||
~ | Show previous messages from tmux, if any | ||
$ | Rename the current session | ||
0 to 9 | Select windows 0 to 9 | ||
c | Create a new window | ||
C-b | Send the prefix key (C-b) through to the application | ||
C-o | Rotate the panes in the current window forwards | ||
C-Up, C-Down, C-Left, C-Right | Resize the current pane in steps of one cell | ||
C-z | Suspend the tmux client | ||
D | Choose a client to detach | ||
d | Detach the current client | ||
f | Prompt to search for text in open windows | ||
i | Display some information about the current window | ||
l | Move to the previously selected window | ||
L | Switch the attached client back to the last session | ||
M | Clear the marked pane | ||
m | Mark the current pane (see select-pane -m) | ||
M-1 to M-5 | Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled | ||
M-n | Move to the next window with a bell or activity marker | ||
M-o | Rotate the panes in the current window backwards | ||
M-p | Move to the previous window with a bell or activity marker | ||
M-Up, M-Down, M-Left, M-Right | Resize the current pane in steps of five cells | ||
n | Change to the next window | ||
o | Select the next pane in the current window | ||
p | Change to the previous window | ||
Page Up | Enter copy mode and scroll one page up | ||
q | Briefly display pane indexes | ||
r | Force redraw of the attached client | ||
s | Show all windows in one window. Back to the active window with q | ||
Space | Arrange the current window in the next preset layout | ||
t | Show the time | ||
Up, Down, Left, Right | Change to the pane above, below, to the left, or to the right of the current pane | ||
w | Choose the current window interactively | ||
x | Kill the current pane | ||
z | Toggle zoom state of the current pane |
Configuration from file
Run the following script to start a tmux session with one windows which has 3 panes
#!/bin/sh # # Setup a workspace called Workspace with one window # The window has 3 panes. # The first pane, 0, set at 70%, split horizontally # pane 0 is again split at 25%, split vertically # session="Workspace1" cd ~ # set up tmux tmux start-server # create a new tmux session tmux new-session -d -s $session -n Session1 # Split pane 0 horizontal by 70% tmux splitw -v -p 70 # Select pane 0 tmux selectp -t 0 # Split pane 0 vertiacally by 25% tmux splitw -h -p 25 # Finished setup, attach to the tmux session! tmux attach-session -t $session
In a chroot environment
In the chroot environment
mkdir -p usr/bin cp /usr/bin/tmux usr/bin vi .profile # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$HOME/usr/bin:$PATH" fi source .profile cp /usr/lib/x86_64-linux-gnu/{libutil.so.1,libutempter.so.0,libevent-2.1.so.6,libresolv.so.2 usr/lib/x86_64-linux-gnu,libpthread.so.0} usr/lib/x86_64-linux-gnu/
Errors
$ tmux tmux: invalid LC_ALL, LC_CTYPE or LANG
What did not solve the issue
- Add export LANG=en_US.UTF-8 to .bashrc
- Add export LANG=en_US.UTF-8 to .profile
- Add locale.conf to etc/
- cp -v /usr/sbin/update-locale usr/sbin/; usr/sbin/update-locale
However
- bash-5.0$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_COLLATE to default locale: No such file or directory C POSIX -bash-5.0$ export LC_ALL="en_US.UTF-8" -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) -bash-5.0$ su -bash: su: command not found -bash-5.0$ echo $LC_CTYPE en_US.UTF-8 -bash-5.0$ echo $LC_MESSAGES en_US.UTF-8 -bash-5.0$ echo $LC_COLLATE en_US.UTF-8
- bash-5.0$ localectl set-locale LANG=en_US.UTF-8
localectl: error while loading shared libraries: libsystemd-shared-241.so: cannot open shared object file: No such file or directory
- bash-5.0$ localectl set-locale LANG=en_US.UTF-8
localectl needs:
- libsystemd-shared-241.so
- librt.so.1
- librt.so.1
- librt.so.1
- librt.so.1
- libcap.so.2
- libcap.so.2
- libcap.so.2
- libcap.so.2
- libacl.so.1
- libcryptsetup.so.12
- libgcrypt.so.20
- libip4tc.so.0
- libkmod.so.2
- libmount.so.1
And more
Useful links
tmux on Arch Linux
tmux_2.4_copy_mode_vim.md configuration file on Github
tmux cheatsheet
An other cheatsheet
Restore session
Restore tmux session after reboot
10 killer tmux tips
tmuxp and its dependency python3-tmuxp
Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy
RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.