Skip to content

Instantly share code, notes, and snippets.

@EndangeredMassa
Last active October 6, 2015 08:48
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EndangeredMassa/2968046 to your computer and use it in GitHub Desktop.
Save EndangeredMassa/2968046 to your computer and use it in GitHub Desktop.
Tmux Setup
alias tm="~/.tmux/tmux.sh"
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 #(battery.sh)'
# 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
.tmux/
├── setup_facile.sh
└── tmux.sh
.tmux.conf
# 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
#!/bin/sh
if [ $# -eq 0 ]; then
echo attaching to most recent session
tmux a
else
echo attaching to or creating: $1
tmux a -t $1 \
|| ~/.tmux/setup_$1.sh \
|| tmux new-session -s $1
fi
# 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}
[detached]
# subsequent calls just attach to that session
$ tm facile
attaching to or creating: facile
[ tmux window with defined windows and splits ]
{` d}
[detached]
# 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/tmux.sh: line 10: /Users/smassa/.tmux/setup_gotime.sh: No such file or directory
{` d}
[detached]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment