From 75682fb87f018631a53d0e2669afcfcfbd9f66e7 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Sun, 16 Sep 2012 15:37:09 +0200 Subject: [PATCH] Disable auto-start for multiplexers with SSH Do not automatically start multiplexers if the machine is access with a remote connection (SSH). This avoids having the 'remote' screen or tmux session embedded in the local session --- modules/screen/README.md | 9 +++++++++ modules/screen/init.zsh | 3 ++- modules/tmux/README.md | 9 +++++++++ modules/tmux/init.zsh | 3 ++- runcoms/zpreztorc | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/screen/README.md b/modules/screen/README.md index 976b483a..acecc208 100644 --- a/modules/screen/README.md +++ b/modules/screen/README.md @@ -14,6 +14,15 @@ To enable this feature, add the following line to *zpreztorc*: zstyle ':prezto:module:screen' auto-start 'yes' +#### SSH and auto-start + +To avoid having screen sessions inside screen sessions, auto-start is disabled for +SSH access. + +It is possible to re-enable auto-start for SSH sessions with + + zstyle ':prezto:module:screen' remote 'yes' + Aliases ------- diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index 424f6584..8c00533a 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -14,7 +14,8 @@ fi # Auto Start # -if [[ -z "$STY" ]] && zstyle -t ':prezto:module:screen' auto-start; then +if ( [[ -z "$SSH_CLIENT" ]] || zstyle -t ':prezto:module:screen' remote ) && + ( [[ -z "$STY" ]] && zstyle -t ':prezto:module:screen' auto-start ); then session="$( screen -list 2> /dev/null \ | sed '1d;$d' \ diff --git a/modules/tmux/README.md b/modules/tmux/README.md index b5e1011a..02a4e885 100644 --- a/modules/tmux/README.md +++ b/modules/tmux/README.md @@ -21,6 +21,15 @@ To avoid keeping open sessions, this module sets `destroy-unattached off` on the background session and `destroy-unattached on` on every other session (global setting). +#### SSH and auto-start + +To avoid having tmux sessions inside tmux sessions, auto-start is disabled for +SSH access. + +It is possible to re-enable auto-start for SSH sessions with + + zstyle ':prezto:module:tmux' remote 'yes' + Aliases ------- diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index a4648276..f54008fa 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -15,7 +15,8 @@ fi # Auto Start # -if [[ -z "$TMUX" ]] && zstyle -t ':prezto:module:tmux' auto-start; then +if ( [[ -z "$SSH_CLIENT" ]] || zstyle -t ':prezto:module:tmux' remote ) && + ( [[ -z "$TMUX" ]] && zstyle -t ':prezto:module:tmux' auto-start ); then tmux_session='#Prezto' if ! tmux has-session -t "$tmux_session" 2> /dev/null; then diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 66cddb52..65b8ec4a 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -81,6 +81,9 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto start a session when Zsh is launched. # zstyle ':prezto:module:screen' auto-start 'yes' +# Allow auto-start with an SSH connection +# zstyle ':prezto:module:screen' remote 'yes' + # # SSH-Agent # @@ -118,3 +121,5 @@ zstyle ':prezto:module:terminal' auto-title 'yes' # Auto start a session when Zsh is launched. # zstyle ':prezto:module:tmux' auto-start 'yes' +# Allow auto-start with an SSH connection +# zstyle ':prezto:module:tmux' remote 'yes'