One of the important features of tmux is that the configuration of split panes will be kept after reattaching.
tmux is also allowed multiple people to attach the same tmux session to work together.
I change the hot-key to be Ctrl+x, instead of Ctrl+b, which has a shorter seperation on a keyboard.
Moreover, I change parts of keys to be vim-like style.
To activate these settings, put ".tmux.config" at your home directory.
-
Quickly create a tmux session:
tmux
In this case, the created sessions will be named by numbers.
To rename a session: Ctrl+x then $
-
Create a named tmux session:
tmux new-session -s session-name [OR] tmux new -s session-name
-
Check current sessions:
tmux list-sessions [OR] tmux ls
-
Exit the current session (as the way you logout on the terminal):
exit
-
Leave the current session but keep your jobs running: Ctrl+x then d (detach)
To resume the session:
tmux attach-session -t session-name [OR]
tmux a -t session-name
-
Stop a session:
tmux kill-session -t session-name
-
Stop all sessions:
tmux kill-server
tmux provides an environment of mulitple workspace/desktops, which are called "windows".
As you create a session, there is a window.
-
Create a new window: Ctrl+x then c
-
Move to next/previous window: Ctrl+x then n/p
-
Close the current window:
exit
As you create a window, there is a pane.
tmux could split the current window to be several panes.
-
Split the window horizontally: Ctrl+x then s
-
Split the window vertically: Ctrl+x then v
-
Move to other panes: Ctrl+x then Arrow-up/down/right/left or h/j/k/l
-
Adjust the location of boundary among panes: Ctrl+x then hit Ctrl+Arrow-up/down/right/left for several times
-
Close the current pane:
exit
-
Enlarge the current pane to fullscreen: Ctrl+x then z
To resume: Ctrl+x then z
- Scroll up/down in a pane: Ctrl+x then PageUp/PageDown
To exit the scrolling mode: Enter
P.S. Mouse wheel can't scroll, before enter the scrolling mode.
Instead of that, it can show the command history.
- Home and End are also deactivated in tmux panes.
Alternatively, use Ctrl+A and Ctrl+E as Home and End.
- Copy text in tmux:
If it is one-line text, as usual, just select the text and then copy.
If it was not, we can (1) enter the copy mode: Ctrl+x then [
(2) move the focus to the text,
(3) hit Space at the begginning location of the text,
(4) move to select whole text,
(5) hit Enter to declare the end of the text,
(6) Ctrl+x then ] to paste somewhere you like.