Skip to content

Commit

Permalink
More control over multiplexer auto-start and SSH
Browse files Browse the repository at this point in the history
Setting the auto-start 'remote' and 'local' styles for the screen and
tmux modules to true automatically starts a session for SSH connections
and for local terminals respectively.
  • Loading branch information
gdiscry committed Jun 3, 2013
1 parent 16aa48b commit 27088b8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
11 changes: 9 additions & 2 deletions modules/screen/README.md
Expand Up @@ -10,9 +10,15 @@ Settings

Starts a GNU Screen session automatically when Zsh is launched.

To enable this feature, add the following line to *zpreztorc*:
To enable this feature when launching Zsh on a local terminal, add the
following line to *zpreztorc*:

zstyle ':prezto:module:screen' auto-start 'yes'
zstyle ':prezto:module:screen:auto-start' local 'yes'

To enable this feature when launching Zsh on a SSH connection, add the
following line to *zpreztorc*:

zstyle ':prezto:module:screen:auto-start' remote 'yes'

Aliases
-------
Expand All @@ -28,6 +34,7 @@ Authors
*The authors of this module should be contacted via the [issue tracker][2].*

- [Sorin Ionescu](https://github.com/sorin-ionescu)
- [Georges Discry](https://github.com/gdiscry)

[1]: http://www.gnu.org/software/screen/
[2]: https://github.com/sorin-ionescu/prezto/issues
Expand Down
5 changes: 4 additions & 1 deletion modules/screen/init.zsh
Expand Up @@ -3,6 +3,7 @@
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Georges Discry <georges@discry.be>
#

# Return if requirements are not found.
Expand All @@ -14,7 +15,9 @@ fi
# Auto Start
#

if [[ -z "$STY" ]] && zstyle -t ':prezto:module:screen' auto-start; then
if [[ -z "$STY" ]] && ( \
( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' remote ) || \
( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:screen:auto-start' local ) ); then
session="$(
screen -list 2> /dev/null \
| sed '1d;$d' \
Expand Down
15 changes: 11 additions & 4 deletions modules/tmux/README.md
Expand Up @@ -10,12 +10,18 @@ Settings

Starts a tmux session automatically when Zsh is launched.

To enable this feature, add the following line to *zpreztorc*:
To enable this feature when launching Zsh on a local terminal, add the
following line to *zpreztorc*:

zstyle ':prezto:module:tmux' auto-start 'yes'
zstyle ':prezto:module:tmux:auto-start' local 'yes'

It will create a background session named _#Prezto_ and attach every new shell
to it.
To enable this feature when launching Zsh on a SSH connection, add the
following line to *zpreztorc*:

zstyle ':prezto:module:tmux:auto-start' remote 'yes'

In both cases, it will create a background session named _#Prezto_ and attach
every new shell to it.

To avoid keeping open sessions, this module sets `destroy-unattached off` on
the background session and `destroy-unattached on` on every other session
Expand Down Expand Up @@ -47,6 +53,7 @@ Authors

- [Sorin Ionescu](https://github.com/sorin-ionescu)
- [Colin Hebert](https://github.com/ColinHebert)
- [Georges Discry](https://github.com/gdiscry)

[1]: http://tmux.sourceforge.net
[2]: https://github.com/sorin-ionescu/prezto/issues/62
Expand Down
5 changes: 4 additions & 1 deletion modules/tmux/init.zsh
Expand Up @@ -4,6 +4,7 @@
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Colin Hebert <hebert.colin@gmail.com>
# Georges Discry <georges@discry.be>
#

# Return if requirements are not found.
Expand All @@ -15,7 +16,9 @@ fi
# Auto Start
#

if [[ -z "$TMUX" ]] && zstyle -t ':prezto:module:tmux' auto-start; then
if [[ -z "$TMUX" ]] && ( \
( [[ -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'

if ! tmux has-session -t "$tmux_session" 2> /dev/null; then
Expand Down
14 changes: 10 additions & 4 deletions runcoms/zpreztorc
Expand Up @@ -91,8 +91,11 @@ zstyle ':prezto:module:prompt' theme 'sorin'
# Screen
#

# Auto start a session when Zsh is launched.
# zstyle ':prezto:module:screen' auto-start 'yes'
# Auto start a session when Zsh is launched on a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'

# Auto start a session when Zsh is launched on a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'

#
# SSH
Expand Down Expand Up @@ -132,6 +135,9 @@ zstyle ':prezto:module:terminal' auto-title 'yes'
# Tmux
#

# Auto start a session when Zsh is launched.
# zstyle ':prezto:module:tmux' auto-start 'yes'
# Auto start a session when Zsh is launched on a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'

# Auto start a session when Zsh is launched on a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'

0 comments on commit 27088b8

Please sign in to comment.