diff --git a/install.sh b/install.sh index 74afa573..038aa06f 100755 --- a/install.sh +++ b/install.sh @@ -10,6 +10,8 @@ touch ~/.zshenv # Creates .zshenv cat zshenv > ~/.zshenv.default.backup # Backs up .zsh_exports. touch ~/.zsh_functions cat ~/.zsh_functions > ~/.zsh_functions.default.backup # Backs up .zsh_functions . +touch ~/.zsh_tmux +cat ~/.zsh_tmux > ~/.zsh_tmux.default.backup echo "Done!" echo "Installing zsh_aliases." cat zsh_aliases > ~/.zsh_aliases @@ -23,4 +25,7 @@ echo "zsh_exports installed." echo "Installing zsh_functions" cat zsh_functions > ~/.zsh_functions echo "zsh_functions installed." +echo "Installing zsh_tmux..." +cat zsh_tmux > ~/.zsh_tmux +echo "zsh_tmux installed." echo "Installation has completed. Now run 'source ~/.zshrc' to enable the new things." diff --git a/zsh_tmux b/zsh_tmux new file mode 100644 index 00000000..578b0b97 --- /dev/null +++ b/zsh_tmux @@ -0,0 +1,17 @@ +# 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 "remote" with name of server. +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 remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0 + echo "tmux failed to start" +fi diff --git a/zshrc b/zshrc index 9828fe05..51059a97 100644 --- a/zshrc +++ b/zshrc @@ -44,14 +44,4 @@ zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' source ~/.zsh_aliases source ~/.zshenv source ~/.zsh_functions - -## DO NOT PUT ANYTHING BELOW THIS LINE OR YOUR CHANGES MAY GET IGNORED BY BASH! -#sleep 1; - -# Gives second time to press CTRL + C in case you want to prevent action by tmux. - -# Starts tmux always on start of bash, not only on SSH login, and quits from bash when tmux quits. WARNING: I DON'T KNOW WHAT HAPPENS IF YOU DON'T HAVE TMUX INSTALLED! (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 +source ~/.zsh_tmux