# tmux

*Category: CLI Tools | Website: https://github.com/tmux/tmux/wiki*

create and switch between multiple terminal seesions at lighting speed


It's funny to think that I've only known about `tmux` since 2024 because I cannot imagine living without it anymore. tmux is a terminal multiplexer and if that doesn't ring a bell, don't worry, I didn't get the term either when I first heard it. Think of tmux as a command line tool that adds the concept of browser tabs to your terminal. And I know, depending on the terminal you might be using, you already have tabs. But tmux is different in some key aspects:

- tmux does not really on the graphical user interface, so it can run on any linux-based headless server (and on any mac)
- the only visible indication that tmux is running is a small status bar appearing at the bottom of your terminal, so its not really visible tabs that tmux gives you
- tmux is fully scriptable meaning that you can control everything via commands in addition to using keyboard shortcuts

But this might still not explain what tmux does so try this: After you installed it, just start it up by typing `tmux` into your terminal and let's start an infinite process with this command:

```bash
i=1; while true; do echo $i; ((i++)); sleep 1; done
```

now, press *ctrl-b* followed by *c*. You should now see an empty terminal window again which might lead you to believe that you have exited the counting process we just started but you are mistaken. Just press *ctrl-b* followed by *l* and you'll be magically transported back to the first window and hopefully have realized, that tmux gives you multiple terminal windows inside a single terminal application. Hence the name *multiplexer*

To exit out of tmux, you press *ctrl-b* followed by *d* (for *detach*). But now comes the best part: Enter `tmux a` (for *attach*) and all of a sudden, your running process is back and you should see that it has been running in the background the entire time! This even works when closing the terminal application altogether.

You can also split the terminal window vertically and horizontally if that's your cup of tea. I just the split functionality very rarely, I prefer switching between full screen windows to have a little visual clutter on my screen at any given time as possible.

All of the above keyboard shortcuts are the default ones, you can customize everything to your liking. Many people like to use a more ergonomic prefix than *ctrl-b* but I just keep it vanilla so I can use the same muscle memory even on servers that don't have my dotfiles installed

All of the above keyboard shortcuts are the default ones, you can customize everything to your liking. Many people like to use a more ergonomic prefix than *ctrl-b* but I just keep it vanilla so I can use the same muscle memory even on servers that don't have my dotfiles installed

## Highlights

tmux might look simple but its fast and powerful:

- **Speed**: Switching between different windows is instant
- **Customizable**: tmux can easily be tailored to your specific needs. The configuration is done via a tmux.conf file in your dotfiles.
- **Runs on headless servers**: This is probably the biggest use case for tmux because you can log in to a sever, start up a bunch of processes via tmux and then just exit out of the session. The processes will continue running

The last part is actually what got me hooked on tmux in the first place. Before using tmux, I was using a pretty contrived approach for keeping my applications running after ending an ssh session.

## Installation

tmux is available for all major linux distros and macos: [link](https://github.com/tmux/tmux/wiki/Installing)

### macOS

```bash
brew install tmux
```

### Ubuntu/Debian

As stated, there is no official apt package for yazi yet, so you'll have to build it from source via cargo

```bash
sudo apt install tmux 
```

## Plugins

tmux is extensible with plugins, which you can install using the tmux plugin manager - [tpm](https://github.com/tmux-plugins/tpm). After the installation you can then just add the plugin you want to use to your tmux.conf file in your dotfiles directory (usually in the .conf folder in your home directory).

These are the plugins that I currently have installed:

```bash
~/.config/tmux/tmux.conf

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'catppuccin/tmux#latest'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-b'
set -g @plugin 'laktak/extrakto'
set -g @plugin 'omerxx/tmux-sessionx'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'realbogart/tmux-telescope'
set -g @plugin 'alexwforsythe/tmux-which-key'
```


---

*Tags: multiplexer, multi-tasking*
*Supported OS: linux, macos*
