Tmux: Difference between revisions

From Redbrick Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 34: Line 34:
==Windows==
==Windows==


Tmux has a tabbed interface, but it calls its tabs �Windows�. To stay organized, I rename all the windows I use. (Well I don't because I guess I hate myself.
Tmux has a tabbed interface, but it calls its tabs �Windows�. To stay organized, I rename all the windows I use. (Well I don't because I guess I hate myself.


To create a new window
To create a new window
Line 42: Line 42:
To rename the current window
To rename the current window
  tmux rename-window (prefix + ,)
  tmux rename-window (prefix + ,)
To kill just one window
prefix + &


==Panes==
==Panes==
Line 87: Line 89:
  unbind ^A
  unbind ^A
  bind ^A select-pane -t :.+
  bind ^A select-pane -t :.+
[[Category:Helpdesk]]

Latest revision as of 00:54, 26 August 2024

Tmux is a terminal multiplexer

What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. It is a good alternative to screen.

Installation

$ git clone https://github.com/tmux/tmux.git
$ cd tmux
$ sh autogen.sh
$ ./configure && make

Prefix

Shortcuts are all used by pressing the prefix then the shortcut. The default is

Control + b <shortcut>

The prefix can also be changed. (At the end of the wiki)

Session Management

Sessions are useful for completely separating work environments.

To create a new tmux session named session_name

tmux new -s session_name

To attache to an existing tmux session named session_name

tmux attach -t session_name

To switche to an existing session named session_name

tmux switch -t session_name

To list existing tmux sessions

tmux list-sessions

To detach the currently attached session

tmux detach (prefix + d)

Windows

Tmux has a tabbed interface, but it calls its tabs �Windows�. To stay organized, I rename all the windows I use. (Well I don't because I guess I hate myself.

To create a new window

tmux new-window (prefix + c)

To move to the window based on index

tmux select-window -t :0-9 (prefix + 0-9)

To rename the current window

tmux rename-window (prefix + ,)

To kill just one window

prefix + &

Panes

Panes make everything easier, and better!

splits the window into two vertical panes

tmux split-window (prefix + ")

splits the window into two horizontal panes

tmux split-window -h (prefix + %)

swaps pane with another in the specified direction

tmux swap-pane -[UDLR] (prefix + { or })

selects the next pane in the specified direction

tmux select-pane -[UDLR]

selects the next pane in numerical order

tmux select-pane -t :.+

Helpful tmux commands

lists out every bound key and the tmux command it runs

tmux list-keys

lists out every tmux command and its arguments

tmux list-commands

lists out every session, window, pane, its pid, etc.

tmux info

reloads the current tmux configuration (based on a default tmux config)

tmux source-file ~/.tmux.conf

Helpful Configs

These are some tmux configs:

nano .tmux.conf

Remap prefix to Control + a

set -g prefix C-a
unbind C-b
bind C-a send-prefix

Force a reload of the config file

unbind r
bind r source-file ~/.tmux.conf

Quick pane cycling

unbind ^A
bind ^A select-pane -t :.+