Tmux: Difference between revisions

From UMIACS
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=== Introduction ===
=== Introduction ===
tmux is a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. It can also be used to detach processes from their controlling terminals, allowing remote sessions to remain active without being visible.
tmux is a [https://en.wikipedia.org/wiki/Terminal_multiplexer terminal multiplexer] for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. It can also be used to detach processes from their controlling terminals, allowing remote sessions to remain active without being visible.


=== Usage ===
=== Usage ===
Line 6: Line 6:
  # tmux new
  # tmux new


You can also name the session using the -s flag:
You can also name the session using the -s flag. In this example, the session is named ''mysession'':
  # tmux new -s $mysession
  # tmux new -s mysession


If you need to end your ssh session, but want your processes to keep running you can detach the screen session by using:
If you need to end your [[SSH]] session but want your processes to keep running, you can detach the tmux session by using:
  # Ctrl + b d
  # Ctrl-b + d
Then exit as normal.
Then exit as normal.


 
If you have multiple tmux sessions you can detach and reattach them at any time. To list the current tmux sessions running, use:
If you have multiple screen sessions you can detach and reattach them at any time. To list the current screen sessions running, use:
  # tmux ls
  # tmux ls


The output will be similar to this:
The output will be similar to this:
  # user@machine:~$ tmux ls
  # user@machine:~$ tmux ls
  # session1: 1 windows (created Thu Oct 22 10:11:44 2020)
  # mysession: 1 windows (created Thu Oct 22 10:11:44 2020)
  # session2: 1 windows (created Thu Oct 22 10:11:52 2020)
  # session2: 1 windows (created Thu Oct 22 10:11:52 2020)
  # session3: 1 windows (created Thu Oct 22 10:11:58 2020)
  # session3: 1 windows (created Thu Oct 22 10:11:58 2020)


To reconnect to a specific tmux session you may use the attach command:
To reconnect to a specific tmux session you may use the attach command:
# user@machine:~$ tmux a -t mysession
or
  # user@machine:~$ tmux attach -t mysession
  # user@machine:~$ tmux attach -t mysession


===tmux Architecture===
===Window Management===
tmux operates using a system of [[Tmux#Windows|Windows]] and [[Tmux#Panes|Panes]].
In tmux, windows show up at the bottom of your session with a name and a sort number.
Each window can house multiple panes within it.
 
===Windows===
In tmux, Windows show up at the bottom of your session with a name and a sort number.


You can create a new window in your session by using:
You can create a new window in your session by using:
Line 47: Line 38:
You can close the current window using:
You can close the current window using:
  # Ctrl-b &
  # Ctrl-b &
===Panes===
Info for Panes


===Copy Mode===
===Copy Mode===
Line 63: Line 50:
To go to the bottom of the page type:
To go to the bottom of the page type:
  # G
  # G
===Prefix Key===
You can change the prefix keystrok from <code><ctrl>-b</code> to <code><ctrl>-a</code> for example by adding the following to your <code>~/.tmux.conf</code>.
<pre>
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
</pre>

Latest revision as of 15:39, 24 March 2022

Introduction

tmux is a terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. It can also be used to detach processes from their controlling terminals, allowing remote sessions to remain active without being visible.

Usage

To invoke a new tmux session, simply use the following command in a terminal:

# tmux new

You can also name the session using the -s flag. In this example, the session is named mysession:

# tmux new -s mysession

If you need to end your SSH session but want your processes to keep running, you can detach the tmux session by using:

# Ctrl-b + d

Then exit as normal.

If you have multiple tmux sessions you can detach and reattach them at any time. To list the current tmux sessions running, use:

# tmux ls

The output will be similar to this:

# user@machine:~$ tmux ls
# mysession: 1 windows (created Thu Oct 22 10:11:44 2020)
# session2: 1 windows (created Thu Oct 22 10:11:52 2020)
# session3: 1 windows (created Thu Oct 22 10:11:58 2020)

To reconnect to a specific tmux session you may use the attach command:

# user@machine:~$ tmux attach -t mysession

Window Management

In tmux, windows show up at the bottom of your session with a name and a sort number.

You can create a new window in your session by using:

# Ctrl-b c

You can navigate to the next window using:

# Ctrl-b n

You can navigate to the previous window using:

# Ctrl-b p

You can rename the current window using:

# Ctrl-b ,

You can close the current window using:

# Ctrl-b &

Copy Mode

In order to navigate around a page in tmux, You must first enter Copy Mode and then you can start navigating:

To enter Copy Mode use:

# Ctrl-b [

Once in Copy Mode, you can navigate normally using the arrow keys as well as other functions.

To go to the top of the page type:

# g

To go to the bottom of the page type:

# G


Prefix Key

You can change the prefix keystrok from <ctrl>-b to <ctrl>-a for example by adding the following to your ~/.tmux.conf.

# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix