Tmux usage: Difference between revisions

From wikinotes
Line 83: Line 83:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
tmux split-window            # create vertical split, select bottom-most
tmux split-window            # create vertical split, select bottom-most
tmux split-window -h          # create horizontal split, select right-most
tmux select-pane ${direction} # -U/-D/-L/-R Up/Down/Left/Right
tmux select-pane ${direction} # -U/-D/-L/-R Up/Down/Left/Right
</syntaxhighlight>
</syntaxhighlight>

Revision as of 00:56, 15 November 2021

Components

pane:    window-splits. there is always at least one pane per window.
window:  a full terminal-screen. A session may have many windows. A Window may have many panes.
session: Contains one or more windows. Each terminal has one or more sessions, and can switch focus to other sessions.
server:  a tmux server runs all sessions/windows/panes for a login
   +------( window )------+
  /                        \

+-----------------------------+
|             |               | <-+--- panes
|             |               |   |
|             +---------------+   |
|             |               | <-+
+-----------------------------+
| 1 |*2*| 3 |            12:00|  <-- window list
+-----------------------------+

Controlling Tmux

Keybindings

Set these in your tmux.conf.

$prefix + x  # kill-pane

Command-Mode

By default, sending $prefix + : enters command mode.
You can enter tmux commands here directly.

kill-pane

CLI

Pass commands as arguments to tmux directly on the command line.

tmux kill-pane

Scripting Tmux

TODO:

document example

Commands

Sessions

tmux new-session -d -s ${session_name} -c ${cwd}
tmux switch -t ${session_name}
tmux list-sessions

Windows

tmux new-window -t ${session}:${window_num} -n ${window_name} -c ${cwd}
tmux split-window -t ${session}:${window_num} -c ${cwd}
tmux rename-window ${window_name}

Panes

tmux split-window             # create vertical split, select bottom-most
tmux split-window -h          # create horizontal split, select right-most

tmux select-pane ${direction} # -U/-D/-L/-R Up/Down/Left/Right

Notifications

tmux show notifications through the command
tmux display-message -c /dev/pts/0 'message'.