shell-things/zsh_tmux

18 lines
1016 B
Plaintext
Raw Normal View History

2011-10-01 15:14:11 +02:00
# Different ways to start tmux on zsh startup.
# Starts tmux always on start of zsh, not only on SSH login, and quits from bash when tmux quits. (Modified from Cubox's script and William Shallum's tmux on SSH login http://william.shallum.net/random-notes/automatically-start-tmux-on-ssh-login )
#if [[ $TERM != "screen" ]]
#then
# tmux has-session -t 0 && tmux attach-session -t 0 || tmux new-session -s 0 && exit
#fi
# Starts tmux on SSH login. (From http://william.shallum.net/random-notes/automatically-start-tmux-on-ssh-login )
# I personally think that this is more suitable for me than that which I made. TIP: replace "0" with name of computer if you don't ever have direct (physical) access to computer where zsh is running on.
2011-10-01 15:14:11 +02:00
if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
then
STARTED_TMUX=1; export STARTED_TMUX
sleep 1
( (tmux has-session -t 0 && tmux attach-session -t 0) || (tmux new-session -s 0) ) && exit 0
2011-10-01 15:14:11 +02:00
echo "tmux failed to start"
fi