Thursday, September 22, 2011


SkyHi @ Thursday, September 22, 2011
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window

##Sane scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'

#Highlighting the active window in status bar
setw -g window-status-current-bg black
setw -g window-status-current-fg yellow
setw -g window-status-alert-bg black
setw -g window-status-alert-fg cyan  # backwards


tmux new-session -d -s hawkhost

tmux new-window -t hawkhost:1 -n 'Server1' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:2 -n 'Server2' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:3 -n 'Server3' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:4 -n 'Server4' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:5 -n 'Server5' 'ssh root@10.x.x.x'
tmux select-window -t hawkhost:1
tmux -2 attach-session -t hawkhost

Here is my current .tmux.conf:
# vi mode
set-window-option -g mode-keys vi
set-option -g status-keys vi

# misc settings
set-window-option -g utf8 on
set-window-option -g automatic-rename off
set-window-option -g mode-mouse on
set bell-action none

# statusbar
set-option -g status-bg black
set-option -g status-fg yellow
set-option -g status-right '#H %d.%m.%Y %H:%M'
set-window-option -g window-status-current-attr bold

and heres a example project file that i start, when i login to xmonad, that creates all my current project windows and panes:
# creates the environment for the project a

tmux start-server

if ! $(tmux has-session -t ProjectA) 

    cd /srv/www/ProjectA
    tmux new-session -d -s ProjectA -n terminal

    tmux new-window -t ProjectA:1 -n editor
    tmux set-window-option -t ProjectA:1 aggressive-resize on

    cd /srv/www/ProjectA/system/usr/share/doc/database
    tmux new-window -t ProjectA:2 -n database
    tmux split-window -t ProjectA:2
    tmux resize-pane -D -t ProjectA:2.0 20 
    tmux select-pane -t ProjectA:2.0

    tmux new-window -t ProjectA:3 -n log 
    tmux split-window -t ProjectA:3

    cd /srv/www/ProjectA/system/usr/share/doc/test
    tmux new-window -t ProjectA:4 -n test

    tmux send-keys -t ProjectA:1 'vim' C-m
    tmux send-keys -t ProjectA:2.0 'mysql -u root -pmypass ProjectA' C-m
    tmux send-keys -t ProjectA:3.0 'tail -f /srv/www/ProjectA/system/var/log/messages.log' C-m
    tmux send-keys -t ProjectA:3.1 'tail -f /var/log/httpd/error_log' C-m

    tmux select-window -t ProjectA:0


tmux -2 attach-session -t ProjectA