Tmux

Current .tmux.conf file

# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Start window numbering at 1
set -g base-index 1

#history-limit
set -g history-limit 20000

# pane movement
bind-key j command-prompt -p "join pane from:"  "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:"  "join-pane -t '%%'"

#Vi search mode
set-window-option -g mode-keys vi

#Tmux logging in /opt/tmux-log(Prefix alt+shift+p)
#run-shell /opt/tmux-logging/logging.tmux

#Enable mouse scrolling using mouse mode
set -g mouse on

##########################
## Tmux Plugin Manager
# List of plugins
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @yank_selection 'clipboard' #'primary' # or 'secondary' or 'clipboard'
set -g @yank_selection_mouse 'clipboard' # or 'primary' or 'secondary'
#################################

# Show tun0 IP in tmux status bar:
set -g status-right "#[fg=colour0,bg=colour110]#(/home/sid/htb/vpn_ip.sh)#[fg=colour255,bg=colour24] %H:%M %d.%m.%Y "

Sessions

Before creating a new session, cd to preferred directory.
#Create a new session
tmux new -s session_name

#Rename a session
prefix + $

#Detach from a session
prefix + d

#Attach to a session
tmux attach -t session_name

Windows

#Create new window
prefix + c

#Rename current window
prefix + ,

#Close current window
prefix + x

#Switch to next/previous window
prefix + n
prefix + p

#Switch to windows using it's number
prefix 0...9

Panes

#Horizontal split
prefix + %

#Vertical split
prefix + "

#Shift between panes
prefix + arrow_key

#Resize panes (Hold prefix key and adjust using arrow keys)
prefix + arrow_keys

#Zoom a pane
prefix + z

#Conver pane to windows
prefix + !

#Send pane to window
prefix + s    [Enter pane number]

Copy Mode

#Enter copy mode
prefix + [

#Quit copy mode
q

#Search keyword
prefix + [

#Select and copy
Spacebar to select and Enter to copy.

#Paste clipboard
prefix + ]

Misc

#Change default directory for new windows
prefix + :
:attach-session -c new_working_dir

Display VPN IP in Status Bar

vi /home/sid/htb/vpn_ip.sh
#!/bin/bash
[ -d /proc/sys/net/ipv4/conf/tun0 ] && echo " VPN $({ ip -4 -br a sh dev tun0 | awk '{print $3}' | cut -f1 -d/; } 2>/dev/null)"

vi .tmux.conf
# Show tun0 IP in tmux status bar:
set -g status-right "#[fg=colour0,bg=colour110]#(/home/sid/htb/vpn_ip.sh)#[fg=colour255,bg=colour24] %H:%M %d.%m.%Y "

Last updated