up::
tags:: #note/develop #on/computing/tools
# Tmux
[tmux](https://github.com/tmux/tmux/wiki) is a [[Terminal Multiplexer]] for Unix and Unix-like systems.
## The Prefix Key
The default prefix key is `ctrl + b`. This tells the terminal that the upcoming keypresses should go to `tmux` and not the normal shell session.
## Attaching, Detaching, and Re-attaching to `tmux` Sessions
**Detaching from a `tmux` session**: press the prefix key (`ctrl + b`) then press `d`. This will detach your shell session from `tmux` while leaving the `tmux` session running in the background.
**Attaching to an existing `tmux` session**: Run the command `tmux attach` to re-attach to the most recent `tmux` session. The shorthand for this is `tmux a`.
**Listing active `tmux` sessions**: Run the command `tmux list-sessions` to see a list of running `tmux` sessions. The shorthand for this is `tmux ls`.
## Splits and Panes
**Creating a vertical split**: Press the prefix key, then press `%`.
**Creating a horizontal split**: Press the prefix key, then press `"`.
**Moving between splits/panes**: Press the prefix key, then press an arrow key.
## Window Management
**Creating a new window**: Run the command `tmux new-window` while in a `tmux` session or press the prefix key followed by `c`.
**Switching to the previous window**: Press the prefix key, then press `p`.
**Switching to the next window**: Press the prefix key, then press `n`.
**Closing a window**: Press the prefix key and then press `&`.
**Renaming a window**: Press the prefix key, then press `,`. Or use the command `tmux rename-window $NAME`.
## Session Management
> [!tip]
> Nesting `tmux` sessions should be done with care.
**Attaching to a specific session**: Run the command `tmux attach -t $SESSION_NAME`. The `-t` is short for `target`. Session names can be found using `tmux list-sessions`.
**Renaming a session**: Run the command `tmux rename-session $SESSION_NAME`, or press the prefix key followed by `
.
**Switching between sessions without detaching**: Press the prefix key followed by `s`.
## Customizing `tmux`
The config file lives at `~/.tmux.conf`.
## References
*Learn Tmux (Part 1) Boost Your Linux Productivity with This 5-Part Course!*, 2023. [https://www.youtube.com/watch?v=UxbiDtEXuxg](https://www.youtube.com/watch?v=UxbiDtEXuxg).
*Learn Tmux (Part 2) - How to Use Splits and Panes for the Ultimate Linux Workflow!*, 2024. [https://www.youtube.com/watch?v=umUalToecsA](https://www.youtube.com/watch?v=umUalToecsA).
*Learn Tmux (Part 3) - A Simple and Straight-Forward Look at Managing Windows*, 2023. [https://www.youtube.com/watch?v=OxscYpQsz_c](https://www.youtube.com/watch?v=OxscYpQsz_c).
*Learn Tmux (Part 4) - Discover How to Manage Sessions within Tmux*, 2024. [https://www.youtube.com/watch?v=zID5TGbi4Pg](https://www.youtube.com/watch?v=zID5TGbi4Pg).
*Learn Tmux (Part 5) - How to Customize Tmux and Make It Your Own!*, 2023. [https://www.youtube.com/watch?v=-f9rz7joEOA](https://www.youtube.com/watch?v=-f9rz7joEOA).
GitHub. “Tmux Wiki.” Accessed September 2, 2024. [https://github.com/tmux/tmux/wiki/Home](https://github.com/tmux/tmux/wiki/Home).