Get started with tmux

image

Configuration

Edit $HOME/.tmux.conf.

Keyboard shortcut

  • Reload .tmux.conf
    Reload configuration file with Ctrl-b r:

    bind-key r source ~/.tmux.conf
    
  • Last active window
    By default, you need to press Ctrl-b l to go to the last window. For faster typing, you can set it to Ctrl-b-b:

    bind-key C-b last-window
    
  • Switch pane
    By default, shortcut for switch pane is Ctrl-b ArrrowKey, add shortcut Alt-ArrowKey for faster switching:

    bind -n M-Left select-pane -L
    bind -n M-Right select-pane -R
    bind -n M-Up select-pane -U
    bind -n M-Down select-pane -D
    

Theming

Make tmux status bar clean.

set -g status-justify left
set -g status-style "bg=colour0"
set -ag status-style "fg=colour7"
set -g status-left ''

set -g status-right  "'#H'    #[fg=colour15]#(date +"%H:%M")  "
set -ag status-right "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y") "

set -g window-status-current-format "#[fg=colour15] #F#I:#W#F "
set -g window-status-format "#[fg=colour8] #F#I:#W#F "

set -g default-terminal "screen-256color"

Common use

Command/Shortcut Action
tmux Start new session
tmux new -s saymyname Start new session with name saymyname
Ctrl-b ? See all keybindings
Ctrl-b c Create new window
Ctrl-b , Rename window
Ctrl-b 1 Go to window 1
Ctrl-b-b Go to the last-active window
Ctrl-b " Split window horizontally
Ctrl-b % Split window vertically
Ctrl-b ArrowKey, Alt-ArrowKey Switch pane
Ctrl-b ESC-[1-5] Change panel layout to style 1 to 5
Ctrl-b z Toggle zoom for pane
Ctrl-b [ Change to scroll mode (‘q’ to quit)
Ctrl-b d Detach current session
tmux ls Show all sessions
tmux a Attach last session
tmux a -t saymyname Attach session with name saymyname
tmux 
comments powered by Disqus