public
Last active

Tmux Setup

  • Download Gist
.bashrc
Shell
1
alias tm="~/.tmux/tmux.sh"
.tmux.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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
directory_structure.txt
1 2 3 4
.tmux/
├── setup_facile.sh
└── tmux.sh
.tmux.conf
setup_facile.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# 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
tmux.sh
Shell
1 2 3 4 5 6 7 8 9 10 11
#!/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
usage.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 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]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.