Tmux is a terminal multiplexer. It can have multiple plexes ;) Yea, odd word.
It lets you switch easily between several terminals within a single terminal "session", detach them (they keep running in the background as a session) and reattach them from other terminal(s).
Why Tmux?
- Protect running programs on a remote server from connection drops by running them inside tmux.
- Allow programs running on a remote server to be accessed from multiple different terminals and/or computers.
- Work with multiple programs and shells together in one terminal, a bit like a window manager inside your terminal.
Features
Sessions
Typically you will only have a single session but you can have multiple session if needed.
A Session will have at least one "Window".
Windows
Think of Windows as "Tabs".
Multiple panes are grouped together into windows.
Panes
A pane contains a terminal.
Server and Client(s)
Tmux keeps all its state in a single main process, called the Tmux server. This runs in the background and manages all the programs running inside Tmux and keeps track of their output. The Tmux server is started automatically when the user runs a tmux command and by default exits when there are no running programs.
Users attach to the tmux server by starting a client. This takes over the terminal where it is run and talks to the server using a socket file in /tmp. Each client runs in one terminal, which may be an X(7) terminal such as xterm(1), the system console, or a terminal inside another program (such as tmux itself). Each client is identified by the name of the outside terminal where it is started, for example /dev/ttypf.
Integration with My Workflow
When I first started using tmux, I felt as if I really was not getting much benefit, but before long I started to realize the huge benefits it gave me.
Tmux augments(big word eh!?) my workflow:
- having multiple projects/tasks/one-offs left in the state I left them.
- Seemless navigation between Neovim Windows and Tmux Panes
- Working on/from multiple computers/servers, I can pick up where I left off in terminals.
- Not really mentioned by many but tmux can be used as a "collaborative" terminal as well. Nerd Beavis has tmux running on his computer say working in a project open in Neovim and hits up nerd Butthead about an issue he is having. Butthead simply ssh's to Beavis's computer and opens the same tmux session and BOOM! Butthead sees and starts navigating in Beavis's Neovim session as Beavis watches.
Some of my custom configuration:
- "Prefix" mapped to [CTRL] + [SPACE], instead of default [CTRL] + [b]
- I moved the info bar from bottom(default) to top.
- Changed info bar color from default green to obnoxious pink to make it VERY obvious I am in a tmux session.
- Added plugins "Resurrect" and "Continuum" to auto save my sessions in case of a system crash/reboot.
Getting Started
Install via your Linux OS package manager, configure in ~/.config/tmux/, and you're ready to go. The defaults are okay, but customization makes it fit your ways of doing things and your looky feely preferences.
