Tmux Basics
TMUX basics
What Is tmux?
tmux is a terminal multiplexer. It lets us use a single environment to launch multiple terminals, or windows, each running its own process or program.
Installing tmux
OSX
$ brew install tmux
Linux
$ sudo apt-get install tmux
Starting tmux
$ tmux
Exiting tmux
$ exit
Creating named session which can be used we want the session to run the background
$ tmux new-session -s session-name
OR
$ tmux new -s session-name
Command Prefix : CRTL-b is way of telling the next command is for tmux and not the application its running
Attaching
In normal terminal if we close the terminal all the session would expire whereas in tmux its not the case.
Any program we start in session will be running .
We can see the list of tmux sessions running
$ tmux list-sessions
OR
$ tmux ls (if no name is provided the list session is named by numbers)
Detaching from the session using
CRTL-b d
We attach back to the session
$ tmux attach (if only one session is running)
$ tmux attach -t session-name
We can kill the session by
$ exit (within the tmux session )
OR
$ tmux kill-session -t session-name
It ask for confirmation before killing the window
CRTL-b &
Creating a new window
CRTL-b c
Renaming window from default name , default name of the window will be the application its running
CRTL-b ,
To navigate around the windows windows using
CRTL-b n (next)
CRTL-b p (previous)
CRTL-b 0-9 (if you have more the windows)
CRTL-b f (to find the window by its name )
CRTL-b w (dsiplays visual menu of windows and you can select them)
Panes : In Tmux we can divide a single session in
Vertical split
CRTL-b %
Horizontal split
CRTL-b "
We can navigate around the window using
CRTL-b o
OR
CRTL-b arrow keys (UP , DOWN , LEFT , RIGHT)