Skip to content

Instantly share code, notes, and snippets.

@mrdaemon
Created November 22, 2012 03:02
Show Gist options
  • Save mrdaemon/4129227 to your computer and use it in GitHub Desktop.
Save mrdaemon/4129227 to your computer and use it in GitHub Desktop.
Tmux configuration
# whatever [...]
[[ -f ~/.tmux-bootstrap.sh ]] && source ~/.tmux-bootstrap.sh
#!/bin/bash
# Shitty tmux bootstrap script for auto-login and session planning
SESSIONNAME="hack"
hash tmux || { echo "Could not find tmux? Ensure it's in \$PATH" ; exit 1 ;}
check_session() {
tmux list-sessions | cut -d ':' -f '1'| \
egrep "^""$SESSIONNAME""\$" 2>&1 > /dev/null
return $?
}
# bootstrap session if not already started.
check_session || tmux -u -2 source-file $HOME/.tmux-sessions.conf
# Attach to session if not running inside tmux already.
if [[ -z "$TMUX" ]] ; then
check_session && tmux -u -2 attach -t hack
fi
# Server Sessions
new -d -s servers
set remain-on-exit on
neww -d -t servers -n rtorrent /home/supernaut/local/bin/rtorrent
neww -d -t servers -n iwakura /home/supernaut/bin/runlain.sh
neww -d -t servers -n cyanure /home/supernaut/bin/runcyanure.sh
neww -d -t servers -n cyanure-en /home/supernaut/bin/runjavasinn.sh
neww -d -t servers -n DoomServer /home/supernaut/bin/doom-server
new -s hack -n Shell
neww -d -t hack -n irc irssi
# Some monitors
neww -d -t hack -n top $HOME/local/bin/htop
neww -d -t hack -n log 'watch -n 120 tail -n 5 /var/log/syslog /var/log/auth.log /var/log/dmesg'
neww -d -t hack -n bandwidth /usr/bin/bmon
neww -d -t hack -n mail alpine
# Dee's tmux configuration file
# start window indexing at one instead of zero
set -g base-index 1
# Bell in any window results in term bell
set -g bell-action any
# Home as default path
set -g default-path ~/
# Enablan 256color term
set -g default-terminal screen-256color
# urxvt specific hack, prevents ITALICS EVERYWHERE instead of reverse
set -g terminal-overrides 'rxvt-unicode*:sitm@...@'
# Default shell and command for windows
set -g default-command /bin/bash
set -g default-shell /bin/bash
# Enable mouse for selection of panes
# (Disabled because it breaks most of my term's select functionality)
#set -g mouse-select-pane on
# Prefix key is Control+a, because I am way too used to screen
unbind C-b
set -g prefix C-a
# Emulate behavior of screen's C-a, A (rename window)
unbind A
bind A command-prompt "rename-window %%"
# Splitting keybinds
unbind %
bind h split-window -v
unbind '"'
bind v split-window -h
# Pane resize keybinds
unbind J
bind-key -r J resize-pane -D 5
bind-key -r K resize-pane -U 5
bind-key -r H resize-pane -L 5
bind-key -r L resize-pane -R 5
bind-key -r M-j resize-pane -D
bind-key -r M-k resize-pane -U
bind-key -r M-h resize-pane -L
bind-key -r M-l resize-pane -R
# copy mode, scree-like, also vi bindings
unbind [
bind Escape copy-mode
setw -g mode-keys vi
# Send prefix to window (i.e. nested screen/session)
bind-key a send-prefix
# Toggle last window (screen, again)
bind-key C-a last-window
# Confirm window kills
#bind-key k confirm kill-window
#bind-key K confirm kill-server
# Toggle statusbar
bind-key b set-option status
# cycle windows with left/right
#bind-key right next
#bind-key left prev
# lock server with C-x, like screen, again.
bind x lock-server
# Refresh draw
bind l refresh-client
# Run command in split
bind / command-prompt "split-window 'exec %%'"
# Enable utf-8
set-window-option -g utf8 on
# Hueg buffer
set -g history-limit 10000
# watch activity on all windows
set -g bell-action any
# Enable titles
set -g set-titles on
# Source sessions
bind I source-file ~/.tmux-sessions.conf
# Reload Config
bind R source-file ~/.tmux.conf
#-- Misc Colours --------------------------------------------------------------
# Border Colours
set -g pane-active-border-bg default
set -g pane-active-border-fg colour240
set -g pane-border-bg default
set -g pane-border-fg colour235
#-- Statusbar -----------------------------------------------------------------
# Status refresh interval in seconds
set -g status-interval 5
# Default sb colours (256 -- love me some gray)
set -g status-bg colour235
set -g status-fg white
# Left shit (session name, bright blue)
set -g status-left '#[fg=blue]#S'
set -g status-left-attr bright
# Right shit
set -g status-right '#[fg=blue,bright]#(hostname)#[default] [#(cut -d " " -f 1-4 /proc/loadavg)] #[fg=white,bright]%H:%M'
# Window title colors
set-window-option -g window-status-fg colour240
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg colour237
set-window-option -g window-status-current-attr default
# Center windows
set-option -g status-justify centre
# Command/message line colors
set -g message-fg black
set -g message-bg green
@reboot . /etc/profile ; cd $HOME && . ~/.profile ; "tmux" -2 -u start-server \; source-file $HOME/.tmux-servers-session.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment