Home > bash > tmux – Notes

tmux – Notes

I started using tmux. It is genuinely easier to use than screen. I have used screen for a while, but I never bothered to learn more commands. I would not consider myself a screen power user so maybe that is why I prefer using tmux.

Basic commands for tmux

1. Creating named sessions

$ tmux new-session -s <name_of_session>


$ tmux new -s <name_of_session>

2. To view sessions

$ tmux list-sessions


$ tmux ls

3. To attach to a session

$ tmux attach -t <name_of_session>

4. To detach from a session

$ Cntrl-b d

5. To kill/destroy a session

$ tmux kill-session -t <name_of_session>

6. Working with Windows

$ tmux new -s <name_of_session> -n <name_of_window>

Cntrl-b c # Create a new window.
Cntrl-b , # Rename window. It defaults to whatever is running on the window.
Cntrl-b n # Move to the next window.
Cntrl-b p # Move to the previous window.
Cntrl-b F # Find window if named, else they are numbered.
Cntrl-b w # Display visual menu of the windows.
Cntrl-b [0-9] # Can move to a particular window by typing the number eg Cntrl-b 1; Cntrl-b 2; etc.
Cnrtl-b x # Closes the current pane or window after prompting for confirmation.
Cntrl-b <space> # Cycles through the various panes layout.
Cntrl-b z # With -Z, the active pane is toggled between zoomed (occupying the whole of the window) and unzoomed (its normal position in the layout).

[Updated 2017-04-26]
7. Copy mode

$ Cntrl-b [ # Enter copy mode
Highlight the text to be copied. Use arrow keys or mouse if possible.
$ Cntrl-b ] # Paste the contents of the buffer
$ Cntrl-b = # View buffer. Press enter to select item in buffer.

My current tmux config

# set shell
set -g default-shell /usr/bin/zsh

# UTF is great, let us use that
set -g utf8
set-window-option -g utf8 on

# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"

# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b
# Ctrl-a Ctrl-a to send an actual Ctrl-a character to the terminal
bind-key C-a send-prefix

# command delay? We don't want that, make it short
set -sg escape-time 1

# Set the numbering of windows to go from 1 instead
# of 0 - silly programmers 😐
set-option -g base-index 1
setw -g pane-base-index 1

# Allow us to reload our Tmux configuration while
# using Tmux
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Getting interesting now, we use the vertical and horizontal
# symbols to split the screen
bind | split-window -h
bind - split-window -v

# hjkl pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

tmux: Productive Mouse-Free Development 1st Editionby Brian P. Hogan (Author)

Categories: bash Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.