prezto/modules/tmux/init.zsh

47 lines
1.3 KiB
Bash
Raw Normal View History

#
# 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>
# Georges Discry <georges@discry.be>
# Xavier Cambar <xcambar@gmail.com>
#
2012-07-23 15:00:44 -04:00
# Return if requirements are not found.
if (( ! $+commands[tmux] )); then
return 1
fi
2012-08-04 14:48:32 -04:00
#
# Auto Start
2012-08-04 14:48:32 -04:00
#
if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \
( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) ||
( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \
); then
tmux_session='prezto'
2012-03-20 15:40:43 +00:00
# Create the default '#Prezto' session if not available.
2012-03-20 15:40:43 +00:00
if ! tmux has-session -t "$tmux_session" 2> /dev/null; then
tmux start-server \; new-session -d -s "$tmux_session" \; set-option -t "$tmux_session" destroy-unattached off &> /dev/null
fi
2012-03-20 15:40:43 +00:00
#By default, prezto sets destroy-unattached to on
tmux_destroy_unattached=`tmux show-options -v -g destroy-unattached`
if [[ -z "$tmux_destroy_unattached" ]]; then
tmux set-option -g destroy-unattached on
fi
2012-03-20 15:40:43 +00:00
#Opens the session '#Prezto' or the latest session used
exec tmux attach-session
fi
2012-08-04 14:48:32 -04:00
#
2012-07-03 13:50:25 -04:00
# Aliases
2012-08-04 14:48:32 -04:00
#
2012-08-15 07:55:01 -04:00
alias tmuxa='tmux attach-session'
alias tmuxl='tmux list-sessions'