home works snippets

Tmux basics

For a quickstart, let’s create a new session with Tmux. The session will be named hibiscus-mint:

tmux new -s hibiscus-mint

Now, we get a new terminal session, but with moar power. We can manage other terminal sessions with Tmux commands. Keep in mind that Tmux commands works only when we are running a Tmux session, and for any Tmux command to run, it needs to start with Control + b. By this we mean hold Control and hit b.

For example, a Tmux command to open a new terminal window is c. Press Control + b + c to open a new terminal window. Here are a list of commonly used commands.

With Control + b

Let’s detach from our hibiscus-mint session with the following command:

Control + b + d

Now we are back to our regular terminal. We can see that hibiscus-mint is still running in background with the following command:

tmux ls

Here are few bash commands to manage Tmux sessions:

tmux new -s session-name            # Create a new session.
tmux ls                             # List currently running session.
tmux attach -t session-name         # Attach the existing session.
tmux kill-session -t session-name   # Kill the existing session.

As we saw earlier, we can create another session, and the existing session will continue to run.

For more Tmux commands, here is a quick cheatsheet.