Tmux
1. Tmux Commands
Command | |
---|---|
Start a new session | tmux |
tmux new -s # |
|
Attach to last session | tmux a |
tmux a -t # |
|
Show all sessions | tmux ls |
Kill session | tmux kill-session -t # |
Ctrl + b & |
|
Kill all sessions but the current | tmux kill-session -a |
tmux kill-session -a -t # |
1.1. Shortcut
Prefix Ctrl + b
.
# Sessions
s list sessions
$ name session
# Windows (tabs)
0-9 switch window
c create window
w list windows
n next window
p previous window
f find window
, name window
& kill window
# Panes (splits)
arrow switch pane
% vertical split
" horizontal split
o switch pane
q show pane numbers
q 0-9 select pane by number
x kill pane
{ (Move the current pane left)
} (Move the current pane right)
z toggle pane zoom
1.2. Resurrect plugin
- Save a tmux session
Ctrl + B + S
. - Resurrect a tmux session
Ctrl + B + R
.
2. Tmux configuration
- Save config file
~/.tmux.conf
. - Restart tmux
tmux source-file ~/.tmux.conf
.
# Improve colors
set -g default-terminal 'screen-256color'
# Set scrollback buffer to 10000
set -g history-limit 10000
# Customize the status line
set -g status-fg green
set -g status-bg black
# split panes using | and -
#bind | split-window -h
#bind - split-window -v
#unbind '"'
#unbind %
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Tmux Resurrect
set -g @plugin 'tmux-plugins/tmux-resurrect'
#set -g @resurrect-processes 'conda "~activate fyp"'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
3. Bash script
Refer here.