Using GNU tmux

From D3xt3r01.tk
Jump to navigationJump to search

WHY

Because I'm tired of screen getting locked and wasting my time .. I thought I'd give tmux a chance.

HOW

First thing I did was try to make tmux use my old ways .. at least a part of them. Here's the content of my ~/.tmux.conf

set-window-option -g clock-mode-colour blue
set-window-option -g monitor-activity on
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left-length 30
set -g status-left '#(whoami)@#(hostname -s)'
set -g status-right '#(cut -d " " -f 1-3 /proc/loadavg) %y-%m-%d %H:%M:%S'
set-window-option -g window-status-current-bg red
set-window-option -g window-status-current-fg black
set-window-option -g automatic-rename on
set-option -g status-utf8 on
set -g base-index 0
set-option -sg  escape-time 0
set-option -g   set-titles on
set-option -g   set-titles-string ' #I-#W '
set-option -g   history-limit 100000
set-window-option -g window-status-format ' #I-#W '
set-window-option -g window-status-current-format ' #I-#W '

set -g prefix C-a
unbind C-b
bind C-a send-prefix

unbind r
bind r source-file ~/.tmux.conf \;\
	display "Configuration reloaded"

bind C-n next-window
bind C-p previous-window
bind C-Space next-window
bind C-a last-window

# disable mouse control by default - change 'off' to 'on' to enable by default.
set-window-option -g mode-mouse off
set-option -g mouse-resize-pane off
set-option -g mouse-select-pane off
set-option -g mouse-select-window off
# toggle mouse mode to allow mouse copy/paste
# set mouse on with prefix m
bind m \
    set -g mode-mouse on \;\
    set -g mouse-resize-pane on \;\
    set -g mouse-select-pane on \;\
    set -g mouse-select-window on \;\
    display 'Mouse: ON'
# set mouse off with prefix M
bind M \
    set -g mode-mouse off \;\
    set -g mouse-resize-pane off \;\
    set -g mouse-select-pane off \;\
    set -g mouse-select-window off \;\
    display 'Mouse: OFF'
# zoom this pane to full screen
bind + \
    new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
    swap-pane -s tmux-zoom.0 \;\
    select-window -t tmux-zoom
# restore this pane
bind - \
    last-window \;\
    swap-pane -s tmux-zoom.0 \;\
    kill-window -t tmux-zoom
# Screen lock
set -g lock-after-time 300
bind-key C-x    lock-server
bind-key x      lock-server
bind-key -n M-x lock-server
set-option -g   lock-after-time 0
set-option -g   lock-server on
set-option -g   lock-command "vlock"

Changing window numbers : ctrl + a then ':move-window -t <number>'

Changing window name : ctrl + a then ':rename-window <new-name>'

When you're in tmux you can now use Ctrl+a then type ':source-file ~/.tmux.conf' ( without the quotes ) to reload the config. I've aliased it to Ctrl+a then the letter r !

Another thing that bugs me is that the vlock command doesn't actually lock. If I disconnect and connect again, it's unlocked .. :|

SOURCES

reloading tmux config tmux notes