Tmux
Motivation
At cases, we need to run a long session via SSH for heavy tasks, but the connection is not always stable and might be disconnected. If so, we are going to lose the access to these remote sessions. tmux
can help you reconnect to a disconnected remote terminal (if you run these tasks under tmux
from the very beginning).
Installation
sudo apt install tmux
sudo apt install tmuxp # a python session manager for tmux
Usage
tmux
Outside of a session
tmux # enable tmux in remote terminal before running time-consuming tasks
tmux a # attach to a previous disconnected terminal launched in tmux
tmux ls # list all terminals launched by tmux
tmux kill-session -t target-session # kill a running session
tmux kill-session -a # kill all sessions
tmux kill-server # kill all sessions
Inside of a session
Ctrl+B, and type
1, 2, or other numbers # switch to window
arrow keys # navigate panes
n # go to next window
w # go to window mode
t # add tag
x # kill tagged window
d # detach current session
:kill-session # kill current session
[ # enter scroll mode, press q to quit
To set up mouse scrolling, add the following line to ~/.tmux.conf
:
set -g mouse on # For tmux version 2.1 and up
Note that this setting breaks highlighting and copying text. Use shift+click to maintain this functionality.
tmuxp
tmuxp load config.yaml
Reference
tmux
source code: https://github.com/tmux/tmuxtmuxp
source code: https://github.com/tmux-python/tmuxpTmux Cheat Sheet: https://tmuxcheatsheet.com/
Last updated
Was this helpful?