Skip to content

Instantly share code, notes, and snippets.

@dalbrekt
Last active December 14, 2015 23:09
Show Gist options
  • Save dalbrekt/5163810 to your computer and use it in GitHub Desktop.
Save dalbrekt/5163810 to your computer and use it in GitHub Desktop.
tmux cheat sheet

Tmux

List all key bindings

Ctrl-b ?

Open command prompt

Ctrl-b :

Session

Start a new sesssion with given name

$ tmux new -s session_name

Reconnect to an existing session

$ tmux attach -t session_name

List existing sessions

$ tmux list-sessions | ls
```
Kill all sessions
```
$ tmux kill-sessions
```
Kill session
```
tmux kill-session -t session_name
```
Detach current client
```
Ctrl-b d
```

## Windows
Create a new window
```
Ctrl-b c
```
Rename current window
```
Ctrl-b ,
```
Select next window
```
Ctrl-b n
```
Select last window
```
Ctrl-b l
```
Select window from a list
```
Ctrl-b w
```
Select window by number
```
Ctrl-b 0..9
```
Kill the current window
```
Ctrl-b &
```

## Panes
Split the current window in two panes
```
Ctrl-b % | Ctrl-b v #rebinded
```
Split the current horizontally
```
Ctrl-b " | Ctrl-b h #rebinded
```
Kill the current pane
```
Ctrl-b x
```
Go to next pane
```
Ctrl-b o
```
Show pane number, when number shows type that number to go to that pane
```
Ctrl-b q
```
Kill/close pane
```
Ctrl-b x or type exit
```
Iterate pane layouts
```
Ctrl-b space
```
Move pane
```
Ctrl-b { | }
```


#!/bin/bash
#
# Setting up tmux session with windows, panes etc.
#
SESSIONNAME="dev"
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? != 0 ]
then
tmux new-session -d -s dev
tmux new-window -t $SESSIONNAME:1 -n 'sca'
tmux new-window -t $SESSIONNAME:2 -n 'docker'
tmux new-window -t $SESSIONNAME:3 -n 'scd'
tmux split-window -t $SESSIONNAME:1 -h # vertical
tmux split-window -t $SESSIONNAME:1.0 -v # horizontal
tmux split-window -t $SESSIONNAME:1.1 -v
tmux resize-pane -t $SESSIONNAME:1.2 -U 10
tmux resize-pane -t $SESSIONNAME:1.3 -U 10
tmux split-window -t $SESSIONNAME:2 -h
tmux split-window -t $SESSIONNAME:3 -h
tmux select-window -t $SESSIONNAME:1
tmux select-pane -t 0
tmux send-keys "cd ~/seal/seal-watchtower-back" C-m
tmux select-window -t $SESSIONNAME:1
tmux select-pane -t 2
tmux send-keys "cd ~/seal/seal-watchtower-back" C-m
tmux select-window -t $SESSIONNAME:1
tmux select-pane -t 1
tmux send-keys "cd ~/seal/seal-watchtower-web" C-m
tmux select-window -t $SESSIONNAME:1
tmux select-pane -t 3
tmux send-keys "cd ~/seal/seal-watchtower-web" C-m
tmux select-window -t $SESSIONNAME:2
tmux select-pane -t 0
vbox=$(ps -ef | grep VirtualBox | wc -l)
if [ $vbox -lt 1 ]
then
~/bin/dockervm start
fi
tmux select-window -t $SESSIONNAME:0
fi
tmux attach -t $SESSIONNAME
# use UTF8
set -g utf8
set-window-option -g utf8 on
# make tmux display things in 256 colors
# set -g default-terminal "screen-256color"
set -g default-terminal "xterm-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# shorten command delay
set -sg escape-time 1
# reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind v split-window -h
bind h split-window -v
#### COLOUR (Solarized 256)
# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange
# pane number display
set-option -g display-panes-active-colour colour15 #petrol
set-option -g display-panes-colour colour166 #orange
# status position
set -g status-justify centre
set -g status-left-length 70
set -g status-left "#[fg=green]: #h : #[fg=brightblue]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') docker #[fg=brightblue]#(boot2docker ip)"
#set -g status-right-length 57
set -g status-right "#[fg=#669966]#S #I:#P #[fg=#585858]:: %d %b %Y #[fg=#585858]:: %T ::"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment