Tmux is a terminal Multiplexer . There are several advantages on why should one use tmux
- Terminal Split Screen
- Multiple Terminal Sessions with simple commands
- Run Processes that are not tied to your current sessions. (For Example, Long Running commands can be invoked using Tmux)
- Ability to SSH using Tmux
- Ie, Ability to connect and disconnect sessions at will. Tmux will keep the session alive even if we exit the session.
- Share sessions with another person (Peer Programming)
brew install tmux
If we just want to create a new session with default name, just type the following
tmux
In order to detached from a session
tmux detach
tmux detach #
tmux detach -t <name>
To attach to a session
tmux attach
tmux attach #
tmux attach -t <name>
Just like any other terminal sessions, we can use exit
command to exit tmux sessions
exit
In order to manage configuration of Tmux, we can use the following file
vim ~/.tmux.conf
ctrl-b
--> Prefix used in Tmux to invoke Tmux commands.- NOTE: This only works within Tmux terminals.
Managing Tmux Windows:
-
ctrl-b + c
-- Create a new tmux Window -
ctrl-b + p
-- Tab to previous tmux Window (p - Previous) -
ctrl-b + n
-- Tab to next tmux Window (n - Next) -
ctrl-b + 0-9
-- Switching between tmux window using number -
ctrl-b + w
-- List all Tmux window -
ctrl-b + ,
-- Rename current tmux Window -
ctrl-b + x
- Force kill active session
Splitting Windows:
ctrl-b + %
-- Split Windows Verticallyctrl-b + :
-- It helps us to provide named commands to Tmux. When we use:split-window
we would be abke to splitctrl-b + arrowkeys
-- Switch between different panes within tmux window
Session Management:
-
tmux list-sessions
-- List all tmux sessions -
tmux attach -t newshell
-- Attaching to existing tmux sessions -
ctrl-b + d
-- Detach from the current session
tmux new -s newshell
To destroy all the sessions
tmux kill-server
If inside tmux, and if we want to kill the current session
ctrl-b + x
- Force kill active session
- Configuring tmux config file
- Installing tmuxp for predefined tmux workstation