Tmux in a nutshell a quick tutorial
I had been a fan of screen for a while now, recently i discovered an alternative that allows you to do basically the same but in a much more elegant way.
Tmux is a [terminal multiplexer](https://tmux.github.io/)
First thing to do is update the config to make it a bit more user-friendly.
I have picked up only the stuff i use for this one, there is pretty complete tmux config [here](https://gist.github.com/spicycode/1229612)
####Tmux configuration file (~/.tmux.conf)
```
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling
unbind ^A
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# window splitting
bind-key v split-window -h
bind-key s split-window -v
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
```
After having done this lets go through a few basic shortcuts that would save you a lot of time in the terminal.
#### How does this work
Now that we have changed the prefix key to be Control + A things feel a bit more like in the screen world.
Lets start a new session
```
tmux new -s {{sessioname}}
```
This creates a new tmux session from which you can detach and reattach to. You can also give it a meaningful name by issuing Ctrl + A (release and press) ,
Good but what if you needed to do a lot of other things over the same ssh session ?
Well for that you can just split the windows or create a new window
Lets start with splitting windows.
If you look closely in the config file we specified Ctrl + A, v to do a vertical split and Ctrl + A, s to do a horizontal split
Here I have split my display into 4 equal parts
![](/content/images/2016/06/tmux_split_screens.png)
Now to get from one pane to another use
```
Ctrl + A, { to switch to the left or } to swap panes
to move to a different screen use.
Ctrl + A, <- -> arrow keys
```
up and down keys are also supported this depends on how you split the screen
To create a new window just issue Ctrl+A, c then use Ctrl + A, window index to cycle through them. Remember window indexes are 0 based, so your first window will be 0, second will have index of 1 and so on..
When you are done you can detach yourself from the tmux session by
```
Ctrl+A, D
```
To reconnect to any of the running sessions we need to have its name so we will need to list all the sessions first.
```
ubuntu@ip-10–0–0–15:~$ tmux list-sessions
tutorial: 2 windows (created Sat Jun 4 07:20:45 2016) [154x43]
```
Here a little alias can be in order
```
alias tls=”tmux list-sessions”
```
To attach back you can use
```
tmux attach -t tutorial (this is the session name)
```
for ease of use again a little alias
```
alias ta=”tmux attach -t”
```
This just scratches the surface but its enough to get you started working with tmux.
Happy Multiplexing…