After many years of using screen I recently started getting familiar with tmux. This is my current .tmux.conf and most of it is borrowed from IppSec’s YouTube video:
# Remap prefix to screens, easier to type, same as "screen"
set -g prefix C-a
bind C-a send-prefix
unbind C-b
# Split panes
bind | split-window -h -c "#{pane_current_path}"
bind _ split-window -v -c "#{pane_current_path}"
unbind % # split-window -h
unbind '"' # split-window
# Rename session and window
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"
unbind "\$" # rename-session
unbind , # rename-window
# Quality of life stuff
set -g history-limit 20000
set -g allow-rename off
# Start index of window/pane with 1, because we're humans, not computers
set -g base-index 1
setw -g pane-base-index 1
# Enable mouse support
set -g mouse on
## Join Windows
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
## Move tabs
bind-key Right swap-window -t +1 \; next-window
bind-key Left swap-window -t -1 \; previous-window
# Search mode vi (default is emac)
set-window-option -g mode-keys vi
# Install the tmux-logging plugin via the tmux plugin manager
# To save the whole terminal session of that screen to a file, issue: prefix + Alt + Shift + p
set -g @plugin 'tmux-plugins/tmux-logging'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# To install a plugin (and keep it installed) add a line like: set -g @plugin '...'
# Then while in tmux session do: prefix + I
# To update plugin(s) do: prefix + u
# To uninstall a plugin, remove its line from this file and do: prefix + Alt + u
run '~/.tmux/plugins/tpm/tpm'
Tmux Copy/Paste
With the mouse support enabled in the above config, to copy/paste text, just hold down the “Shift” key and select what you need to copy with the mouse. Then you can do one of the following:
- Don’t let go off the “Shift” key, right-click on the selected text and pick “copy”
- Use the regular Ctrl+Shift+C in which case you don’t have to keep holding the “Shift” key
Tmux Cheat Sheet
Note, that I have overwritten the default keybindings. So, instead of the default “Ctrl+b” I use “Ctrl+a” to initiate a Tmux command. That way it matches the screen emulator and that way I can use the same muscle memory.
My current tmux config