Skip to content

Instantly share code, notes, and snippets.

@andreav
Last active July 28, 2017 23:12
Show Gist options
  • Save andreav/22238a35bd08437eeae0c3e99564fe3b to your computer and use it in GitHub Desktop.
Save andreav/22238a35bd08437eeae0c3e99564fe3b to your computer and use it in GitHub Desktop.
My tmux.conf and django-env-setup.sh
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# vi bidings
setw -g mode-keys vi
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# don't rename windows automatically
#set-option -g allow-rename off
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# ref http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
#!/bin/bash
# Note - numbering from 1 on (see .tmux.conf)
# Note - Copy/Paste from gnome-termial: SHIFT + Select / SHIFT + Central button
SESSION=$USER
WORKINGDIR="$(dirname $0)/../../"
function cd_and_activate {
tmux send-keys "cd $WORKINGDIR" C-m
tmux send-keys 'source ../bin/activate' C-m
tmux send-keys "clear" C-m
}
# -2: forces 256 colors,
tmux -2 new-session -d -s $SESSION
# Runserver window next
#First one rename window, then new-window
tmux rename-window -t $SESSION:1 'Runserver'
tmux split-window -v
tmux select-pane -t 1
cd_and_activate
tmux send-keys "./run_celery.sh PURGE" C-m
tmux select-pane -t 2
cd_and_activate
tmux send-keys './manage.py runserver' C-m
# Git window
tmux new-window -t $SESSION:2 -n 'Git'
cd_and_activate
tmux send-keys "git branch" C-m
tmux send-keys "git status" C-m
# Bash window
tmux new-window -t $SESSION:3 -n 'Bash A'
cd_and_activate
tmux send-keys "./stuff/etc/vim_session.sh" C-m
# Bash window
tmux new-window -t $SESSION:4 -n 'Bash B'
cd_and_activate
# Set default window as the dev split plane
tmux select-window -t $SESSION:3
# Attach to the session you just created
# (flip between windows with alt -left and right)
tmux -2 attach-session -t $SESSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment