2019-05-01 03:29:37 +00:00
|
|
|
# vim: syn=zsh
|
|
|
|
|
|
|
|
# Return if tmux isn't installed.
|
|
|
|
if (( ! $+commands[tmux] )); then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-11-20 21:10:43 +00:00
|
|
|
# If running as root, stop and return.
|
2019-11-25 17:18:31 +00:00
|
|
|
if [ "$EUID" -eq 0 ] ; then
|
2019-11-20 21:10:43 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2019-05-01 03:29:37 +00:00
|
|
|
# If this this terminal meets any of these return.
|
2020-06-27 04:21:13 +00:00
|
|
|
env_array=($TMUX $EMACS $VIM $INSODE_EMACS $VSCODE $POPUP_TTY)
|
2019-05-01 03:29:37 +00:00
|
|
|
if [[ -n $env_array ]]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ( [[ -n "$SSH_TTY" ]] && zstyle -t ':tmux:auto-start' remote ) || \
|
|
|
|
( [[ -z "$SSH_TTY" ]] && zstyle -t ':tmux:auto-start' local ) \
|
|
|
|
; then
|
|
|
|
zstyle -s ':tmux:auto-start' name tmux_session
|
|
|
|
tmux_session=${tmux_session:-tmux}
|
|
|
|
echo $tmux_session
|
|
|
|
tmux start-server
|
|
|
|
if ! tmux has-session 2> /dev/null; then
|
|
|
|
zstyle -s ':tmux:auto-start' name tmux_session
|
|
|
|
tmux \
|
|
|
|
new-session -d -s "${tmux_session:-tmux}" \; \
|
|
|
|
set-option -t "${tmux_session:-tmux}" destroy-unattached off &> /dev/null
|
|
|
|
fi
|
|
|
|
tmux attach -t $tmux_session
|
|
|
|
fi
|