- Minimal config
- Sessions
- Windows
- Panes
- Split current pane horizontally
- Split current pane veritcally
- Resize current pane
- Switch between panes
- Make the current pane full-screen
- Copy and paste text from pane with keyboard
I recommend the following minimal .tmux.conf
# Make zsh default shell
set-option -g default-shell /bin/zsh
# Make vim and tmux speak the 'same' language
set-option -gw xterm-keys on
set-option -sa terminal-overrides ',RGB:RGB'
# Shorter escape time
set -s escape-time 0
# Show working directory
set -g status-left "#{pane_current_path}"
# Increase history-limit for panes
set -g history-limit 20000
# split panes using | and -
bind | split-window -h
bind - split-window -v
# reload config file
bind r source-file ~/.tmux.conf
# switch panes using alt-hjkl without prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
# stop naming windows automatically
#set-option -g allow-rename off
# enable vi-keys
setw -g mode-keys vi
A session is a context which can contain multiple windows with multiple panes inside each. I do personally use this to quickly switch between project contexts.
- Navigate to directory you would like to open a session in
- run
tmux
Press ctrl + b
and then $
Detaching does not close the session and keeps it in the background.
Press ctrl + b
and then d
.
To attach to a detached session (if you currently aren't inside an active session),
run tmux attach
To attach to a specific session, first list all available sessions via
tmux ls
.
Now you can simply attach by using the sessions name as target:
tmux attach -t <sessionName>
If you are currently inside an active session, you can switch by pressing:
ctrl + b
and then s
. Now simply select the session you would like to use with the arrow keys.
You can also use the left and right arrow keys to unfold the session an target a specific window of the session.
Press ctrl + b
and then L
to quickly switch between your last two session. (note the uppercase!)
Detach from your current session and run the following command inside your terminal:
tmux kill-server
. (This fully closes all sessions!)
A window is an arrangement of panes. For example you could have a window containing a pane with an instance of vim as well as two smaller panes running a development server, your test runner or even another instance of vim (or any other editor) showing a README or something. By default a session starts with a single window containing a single pane.
For the purpose of organization it might be helpful to rename your window (e.g. to
have one with your dev
and one with some kind of prod
setup).
To do so, press ctrl + b
and then ,
To open a new window, press ctrl + b
and then c
I usually target windows directly, by using their respective number:
ctrl + b
and then <numberOfTheWindow>
ctrl + b
and then l
(lowercase L)
Panes are split screens comparable to a tiling window manager. You can use these to show different terminals of various sizes inside a single window.
ctrl + b
and then "
ctrl + b
and then %
Open the command mode by pressing:
ctrl + b
and then :
Now type resize-pane -D <number>
. The -D
flag tells tmux to shrink the current pane.
You can use -U
(up), -R
(right) and -L
(left) respectively.
Of course you can map these to shortcuts inside your tmux.conf as well if you would like to.
If you use the config mappings shown at the top of this file, you can easily switch,
by pressing alt +
h/j/k/l
(vim mappings). Unfortunately I can't remember the default
mappings 😅.
You can full-screen your current pane by pressing ctrl + b
and then z
.
To switch off full screen mode, simply switch to another pane or use the shortcut above again.
You can open copy mode by pressing ctrl + b
and then [
.
Now use h/j/k/l
to navigate. To select text press space and select the text with h/j/k/l.
If you are done, press enter. To paste the text somewhere, press ctrl + b
and then ]