Skip to content

Instantly share code, notes, and snippets.

@faejr
Last active May 29, 2016 17:28
Show Gist options
  • Save faejr/fa688df3bbcec00ad56a0dd1ab4ac4b8 to your computer and use it in GitHub Desktop.
Save faejr/fa688df3bbcec00ad56a0dd1ab4ac4b8 to your computer and use it in GitHub Desktop.
Restores or create a new tmux development environment (4 panes)
#!/bin/bash
SESSIONS=$(tmux ls)
RESTORED=false
IFS=':' read -ra SES <<< "$SESSIONS"
if [ ${#SES} != 0 ]; then
for i in "${SES[@]}"; do
if [ "$i" = "dev" ]; then
RESTORED=true
tmux a -t "$i"
fi
done
fi
if [ "$RESTORED" = false ]; then
tmux new-session -s 'dev' -d
tmux split-window -h
tmux split-window -v
tmux select-pane -t 0
tmux split-window -v
tmux select-pane -t 0
tmux new-window 'dev'
tmux -2 attach-session -d
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment