Skip to content

Instantly share code, notes, and snippets.

@mrdaemon
Created July 12, 2011 23:01
Show Gist options
  • Save mrdaemon/1079189 to your computer and use it in GitHub Desktop.
Save mrdaemon/1079189 to your computer and use it in GitHub Desktop.
tmux config and random bullshit
#!/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 -2 source-file $HOME/.tmux-sessions.conf
# Attach to session if not running inside tmux already.
if [[ -z "$TMUX" ]] ; then
check_session && tmux -2 attach -t hack
fi
# Server Sessions
new -d -s servers
set-remain-on-exit on
neww -d -t servers -n rtorrent /usr/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 irssi irssi
# Some monitors
neww -d -t hack -n top /usr/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
# 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
# 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
# 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
# Border color
set -g pane-active-border-bg default
# 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 blue
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 "#22T Up: #(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") %H:%M %d-%b-%y#"
set -g status-right '#[fg=blue,bright]#(hostname)#[default] #[fg=default,bright]#(uptime | cut -d ',' -f 2)#[default] [#(cut -d " " -f 1-4 /proc/loadavg)] #[fg=bl
ue,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
# m h dom mon dow command
@reboot . /etc/profile ; cd $HOME; . ~/.profile ; "$HOME/bin/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