Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the tmux stuff out to it's own file which can be included via the
.profile.local
- Loading branch information
Lori Holden
committed
Feb 12, 2012
1 parent
efff81b
commit 1484e9b
Showing
2 changed files
with
22 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
if [[ -z "$TMUX" ]] && [[ -x `which tmux 2> /dev/null` ]]; then | |||
session_base=lori | |||
# Find stale sessions and let them die | |||
old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) | |||
for old_session_id in $old_sessions; do | |||
tmux kill-session -t $old_session_id | |||
done | |||
|
|||
# Become our base session if we are the first ones here | |||
tmux has-session -t $session_base | |||
if [[ $? -eq 1 ]]; then | |||
tmux new-session -s $session_base | |||
else | |||
session_id="$(date +%Y%m%d%H%M%S)$$" | |||
tmux new-session -d -t $session_base -s $session_id | |||
tmux new-window -t $session_id | |||
tmux attach-session -t $session_id | |||
tmux kill-session -t $session_id | |||
fi | |||
exit | |||
fi |