tmux #
References:
- Command-line Environment · the missing semester of your cs education
- Home · tmux/tmux Wiki
- Tmux Cheat Sheet & Quick Reference
- tmux(1) - Linux manual page
- Tmux 使用教程 - 阮一峰的网络日志
- The best and greatest tmux.conf ever
Session #
In shell:
# New session (s for session)
tmux new -s my-session
# Re-attach to existing session (t for target)
tmux attach -t my-session
tmux a -t my-session
# Stop a session
tmux kill-session -t my-session
# List all tmux sessions
tmux ls
# kill all tmux sessions
tmux kill-serverIn Tmux sessions:
- Detach current session:
<C>b d - Rename current session:
<C>b $
Window (Tab) #
- Create new window:
<C>b c - Close current window:
<C>b & - Rename current window:
<C>b , - Go to window by order:
<C>b 0,<C>b 1, etc. - Go to previous window:
<C>b p - Go to next window:
<C>b n
Panes #
- Split current window into horizontal panes (
=):<C>b " - Split current window into vertical panes (
||):<C>b % - Close current pane:
<C>b x - Move between panes:
<C>b direction-key - Zoom in & out to a pane:
<C>b z - Change pane size:
<C>b <C>direction-key
Configuration #
Change Prefix Key #
In .tmux.conf:
# Remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefixChange Shortcut Key #
For example, in .tmux.conf:
# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %256 Colour #
Set alias (in .zshrc): (credit)
alias tmux='tmux -2'In .tmux.conf:
set -g default-terminal "screen-256color"Scroll & Click to Switch Panes #
Credit: How do I scroll in tmux? - Super User
set -g mouse onAutomatically Rename Window #
In .tmux.conf: (credit)
# Automatically rename status
set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'