Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Tmux Setup
alias tm="~/.tmux/"
set -g default-shell /bin/bash
# window numbers make more sense starting from 1 than 0
set -g base-index 1
set -g status-justify centre
set -g escape-time 0
# remap the mod key to `
set -g prefix `
unbind C-b
# hit `` to type an actual `
bind ` send-prefix
# Status bar formatting
set -g status-left-length 15
set -g status-right-length 15
set -g status-bg black
set -g status-fg white
set -g status-left '#[bg=blue,fg=brightgreen]{#S}#[fg=white]'
set -g status-right '#[fg=brightgreen]%H:%M #('
# keybindings to make resizing easier
bind -r C-h resize-pane -L
bind -r C-j resize-pane -D
bind -r C-k resize-pane -U
bind -r C-l resize-pane -R
# rebind split keys
unbind %
bind | split-window -h
bind - split-window -v
# setup facile environment
cd ~/source/node/facile
# create the facile session
tmux new-session -d -s facile
# create a window for processes
tmux rename-window -t facile:1 'procs'
# start a coffeescript compiler
tmux send-keys -t 1 './coffee' C-m
# split the current window vertically
tmux split-window -v
# run the test suite in the new split
tmux send-keys -t 1 'node test' C-m
# create a window for a simple shell
tmux new-window -t facile:2 -n 'shell'
# create a window for vim
tmux new-window -t facile:3 -n 'vim'
# start vim
tmux send-keys -t 3 'vim .' C-m
# set the starting window
tmux select-window -t facile:3
# attach to the tmux session we just created
tmux a
if [ $# -eq 0 ]; then
echo attaching to most recent session
tmux a
echo attaching to or creating: $1
tmux a -t $1 \
|| ~/.tmux/setup_$ \
|| tmux new-session -s $1
# first call creates the session based on our script
$ tm facile
attaching to or creating: facile
session not found: facile
[ tmux window with defined windows and splits ]
{` d}
# subsequent calls just attach to that session
$ tm facile
attaching to or creating: facile
[ tmux window with defined windows and splits ]
{` d}
# session names that don't have a script are simply created
$ tm gotime
attaching to or creating: gotime
session not found: gotime
/Users/smassa/.tmux/ line 10: /Users/smassa/.tmux/ No such file or directory
{` d}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment