# Tmux

## Cheatsheet and References

1\. [https://gist.github.com/MohamedAlaa/2961058](https://gist.github.com/MohamedAlaa/2961058)

2\. [https://tmuxcheatsheet.com/](https://tmuxcheatsheet.com/)

## Tmux Guide

Quelle: [https://linuxize.com/post/getting-started-with-tmux/](https://linuxize.com/post/getting-started-with-tmux/)

#### Starting Your First Tmux Session

<span class="ezoic-adpicker-ad" id="bkmrk-"></span>To start your first Tmux session, simply type `tmux` in your console:<span class="ezoic-adpicker-ad" id="bkmrk--0"></span>

<div id="bkmrk-tmux">```console-bash
tmux
```

</div>This will open a new session, create a new window, and start a shell in that window.

Once you are in Tmux you’ll notice a status line at the bottom of the screen which shows information about the current session.

You can now run your first Tmux command. For example, to get a list of all commands, you would type:

`Ctrl+b` `?`

#### Creating Named Tmux Sessions

By default, Tmux sessions are named numerically. Named sessions are useful when you run multiple Tmux sessions. To create a new named session, run the `tmux` command with the following arguments:<span class="ezoic-adpicker-ad" id="bkmrk--1"></span>

<div id="bkmrk-tmux-new--s-session_">```console-bash
tmux new -s session_name
```

</div>It’s always a good idea to choose a descriptive session name.<span class="ezoic-adpicker-ad" id="bkmrk--2"></span>

#### Detaching from Tmux Session

You can detach from the Tmux session and return to your normal shell by typing:

`Ctrl+b` `d`

The program running in the Tmux session will continue to run after you detach from the session.<span class="ezoic-adpicker-ad" id="bkmrk--3"></span>

#### Re-attaching to Tmux Session

<span class="ezoic-adpicker-ad" id="bkmrk--4"></span>To attach to a session first, you need to find the name of the session. To get a list of the currently running sessions type:

<div id="bkmrk-tmux-ls">```console-bash
tmux ls
```

</div>The name of the session is the first column of the output.

<div id="bkmrk-0%3A-1-windows-%28create">```output
0: 1 windows (created Sat Sep 15 09:38:43 2018) [158x35]
my_named_session: 1 windows (created Sat Sep 15 10:13:11 2018) [78x35]
```

</div>As you can see from the output, there are two running Tmux sessions. The first one is named `0` and the second one `my_named_session`.<span class="ezoic-adpicker-ad" id="bkmrk--5"></span>

For example, to attach to session `0`, you would type:

<div id="bkmrk-tmux-attach-session-">```console-bash
tmux attach-session -t 0
```

</div>#### Working with Tmux Windows and Panes

When you start a new Tmux session, by default, it creates a single window with a shell in it.<span class="ezoic-adpicker-ad" id="bkmrk--6"></span>

To create a new window with shell type `Ctrl+b` `c`, the first available number from the range `0...9` will be assigned to it.<span class="ezoic-adpicker-ad" id="bkmrk--7"></span>

A list of all windows is shown on the status line at the bottom of the screen.

Below are some most common commands for managing Tmux windows and panes:

- `Ctrl+b` `c` Create a new window (with shell)
- `Ctrl+b` `w` Choose window from a list
- `Ctrl+b` `0` Switch to window 0 (by number )
- `Ctrl+b` `,` Rename the current window
- `Ctrl+b` `%` Split current pane horizontally into two panes
- `Ctrl+b` `"` Split current pane vertically into two panes
- `Ctrl+b` `o` Go to the next pane
- `Ctrl+b` `;` Toggle between the current and previous pane
- `Ctrl+b` `x` Close the current pane

#### Kommando in eine Terminal Session schicken (in den Hintergrund)

<div data-lang="" id="bkmrk-tmux-new-session--d-"><textarea style="display: none;">tmux new-session -d -s SESSIONNAME 'Befehl'</textarea><div><div><textarea spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1px; height: 1em; outline: medium none currentcolor;" tabindex="0" wrap="off"></textarea></div><div><div><div><div><div><div><div>```
<span role="presentation">tmux new-session -d -s SESSIONNAME 'Befehl'</span>
```

</div></div></div></div></div></div><div></div><div><div></div></div></div></div></div>