prezto/modules/tmux/init.zsh
neersighted b54770e40f Improve Tmux startup logic.
Instead of creating a Tmux session, and then moving to the background session,
just create the background session if needed, and always attach to it.

This fixes the need for setting destroy-session on, and thus enables the use
of multiple background sessions.
2013-01-21 17:00:29 -08:00

37 lines
795 B
Bash

#
# Defines tmux aliases and provides for auto launching it at start-up.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Colin Hebert <hebert.colin@gmail.com>
# neersighted <neersighted@myopera.com>
#
# Return if requirements are not found.
if (( ! $+commands[tmux] )); then
return 1
fi
#
# Auto Start
#
if [[ -z "$TMUX" ]] && zstyle -t ':prezto:module:tmux' auto-start; then
tmux_session='#Prezto'
# Check that the default session exists.
if ! tmux has-session -t "$tmux_session" 2> /dev/null; then
# Create a new, detached session only if needed.
tmux new-session -d -s "$tmux_session"
fi
# Attach to the session.
TERM=xterm-256color tmux attach -t "$tmux_session"
fi
#
# Aliases
#
alias tmuxa='tmux attach-session'
alias tmuxl='tmux list-sessions'