Linux/tmux
< Linux
usage
converting from screen to tmux
"Navigating in tmux after using GNU screen requires adjusting to one fundamental change: the default prefix shortcut is Ctrl+b instead of Ctrl+a. However, the core concept of navigating windows remains remarkably similar, while managing "panes" (splits) is significantly easier in tmux." [1]
screen to tmux
| function | screen | tmux |
|---|---|---|
| Start a new session with session name | screen -S session_name |
tmux new -t session_name |
| Create a new window | Ctrl+a c |
Ctrl+b c |
| Switch to next window | Ctrl+a n |
Ctrl+b n |
| Switch to previous window | Ctrl+a p |
Ctrl+b p |
| Reattach to a session | screen -r process_id/session_name |
tmux a -t process_id/session_name |
| Rename session name | Ctrl+a :sessionname session_name |
Ctrl+b $ |
| Split window vertically | Ctrl+a \| |
Ctrl+b % |
~/.tmux.conf
Converted from my screen#.screenrc
$ cat ~/.tmux.conf
# My tmux Configuration - $HOME/.tmux.conf
# Converted from $HOME/.screenrc
# ---------------------------------------------------------------------------
# Prefix - match screen's ctrl+a instead of tmux's default ctrl+b
# ---------------------------------------------------------------------------
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# ---------------------------------------------------------------------------
# autodetach on
# No equivalent needed: the tmux server always keeps sessions alive when the
# client's terminal goes away. Clients detach rather than kill the session.
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# startup_message off
# No equivalent needed: tmux has no startup banner.
# ---------------------------------------------------------------------------
# 10,000 lines of scrollback! (screen: defscrollback 10000)
set -g history-limit 10000
# flash screen on bell (screen: vbell on / vbell_msg)
set -g visual-bell on
set -g bell-action any
set -g monitor-bell on
# clear scrollback with '[ctrl]+a C' (screen: bind C eval "scrollback 0" ...)
# NOTE: tmux 3.2+ binds C to customize-mode by default; this overrides it.
bind C send-keys -R \; clear-history \; display-message "scrollback cleared"
# set default terminal (screen: term linux)
# Deliberate deviation: "linux" would cost tmux 256 colors, italics and
# extended keys. Use "screen-256color" instead if tmux-256color is missing.
set -g default-terminal "tmux-256color"
#set -g default-terminal "screen-256color"
# set default title (screen: shelltitle ".")
# tmux renames the window after the running command automatically.
set -g automatic-rename on
set -g automatic-rename-format "#{b:pane_current_command}"
set -g set-titles on
set -g set-titles-string "#T"
# set default shell (screen: shell /bin/bash)
set -g default-shell /bin/bash
# ---------------------------------------------------------------------------
# hard line status (screen: hardstatus alwayslastline
# "%{= KW} %H %{= Kw}|%{-} %-w%{= bW}%n%f %t%{-}%+Lw")
# ---------------------------------------------------------------------------
set -g status on
set -g status-position bottom
set -g status-justify left
set -g status-interval 5
# %{= KW} - dim-grey text on a bright-white bar
set -g status-style "fg=brightblack,bg=brightwhite"
# %H | - hostname followed by a separator
set -g status-left " #H #[fg=brightblack,bg=white]|#[default] "
set -g status-left-length 40
set -g status-right ""
# %n%f %t - window number, flags, title
setw -g window-status-format "#I#F #W"
setw -g window-status-style "fg=brightblack,bg=brightwhite"
# %{= bW} - current window in blue on bright white
setw -g window-status-current-format "#I#F #W"
setw -g window-status-current-style "fg=blue,bg=brightwhite,bold"
setw -g window-status-separator " "
# go to home dir (screen: chdir)
# tmux inherits the active pane's cwd, so force $HOME explicitly.
bind c new-window -c "$HOME"
bind '"' split-window -v -c "$HOME"
bind % split-window -h -c "$HOME"
# ---------------------------------------------------------------------------
# look and feel (screen: commented-out caption/hardstatus alternates)
# ---------------------------------------------------------------------------
#set -g status-right "%H:%M %a %Y-%m-%d "
#set -g status-right-length 40
#set -g status-position top