Skip to content

Instantly share code, notes, and snippets.

@automata
Last active April 24, 2021 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save automata/2a3e8a276b2fd05ae13d086422dc4140 to your computer and use it in GitHub Desktop.
Save automata/2a3e8a276b2fd05ae13d086422dc4140 to your computer and use it in GitHub Desktop.
Recipe to configure a sweet tmux

Quick and dirty tmux manual ;-)

Install tmux:

sudo apt install tmux

Copy the tmux.conf file bellow to your home:

cp tmux.conf ~/.tmux.conf

Using

To create a new session:

tmux

To attach to an existing session:

tmux a

Concepts

  • Tmux runs sessions to where we can attach clients.
  • Each session can have many windows (listed on bottom)
  • Each window can have many panes (the splitted panes)
  • Each new pane is a new bash prompt/terminal

Common commands

All commands start with C-b (C is the command key on Mac; ctrl key on Linux):

C-b c                     Create a new window
C-b |                     Split window vertically
C-b -                     Split window horizontally
C-b <arrow keys>          Move between panes
C-b <number>              Go to window with number n (listed on bottom)
C-b [                     Enter in "scroll mode". Use arrows and pg down/up to move on pane. Use Enter to exit the mode.
C-b d                     Dettach from session (to get back: tmux a)
# Start window/session index at 1
set-option -g base-index 1
setw -g pane-base-index 1
set -g pane-border-fg '#666666'
set -g pane-active-border-fg '#0000ff'
set -g pane-active-border-bg default
# Easier splits
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# C-b C-b go to last window
bind-key C-b last-window
# Improve colors
set -g default-terminal "screen-256color"
# soften status bar color from harsh green to light gray
set -g status-bg '#666666'
set -g status-fg '#0000ff'
# Status Bar
setw -g monitor-activity on
set -g visual-activity on
# Force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# Stop renaming panels automatically
set-option -g allow-rename off
# Act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# Fix delay when sending escape key
set -sg escape-time 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment