New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable auto-start for multiplexers with SSH #292
Disable auto-start for multiplexers with SSH #292
Conversation
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
Given that this is an extension of auto-start, shouldn't the style be |
I was about to do that, but then I thought it would be better to change
into
So I decided to leave it for now and get some input on which name would be the best. (Just to be clear, it's for tmux and screen, |
If you add enable, you'd probably have to do the same to other zstyles since it's confusing for one to have enable while another does not. I general, if the zstyle is not defined, it has been considered disabled, like git-info formats. |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement is a bit hard to read. It looks to me like it fails on localhost if remote is not set to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understood it after I translated it to something more readable.
( is-false "$_screen_is_on_remote" || is-true "$_screen_auto_start_on_remote" ) && ( is-false "$_screen_is_started" && is-true "$_screen_auto_start")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically:
If we are not in a SSH (remote) session or if starting the multiplexer in a SSH (remote) session is enabled
and, if the multiplexer isn't started and if auto-start is enabled.
👍 |
Good thing I didn't send a pull request before checking the issues. I worked a bit on the same issue but the other way around. In my case the problem is that I want a multiplexer session when connecting with SSH but not when using a local terminal (or when using something like In order to do that, I tweaked the zstyle ':prezto:module:tmux' auto-start 'yes' I added a zstyle ':prezto:module:tmux' auto-start 'ssh' As this issue is about another use case, I won't send the pull request. You can look at my code there: gdiscry/prezto@1ddc656. |
Hum that's actually a very good usecase. I usually have the tmux session started on my local machine and connect without tmux on my remote session, but it could very well be the case for someone else that tmux is started only when accessed through SSH (all of that still applies with screen). Maybe we should have something along the lines of:
If we want to do some backward compatibility we could just say that What do you think? |
I was indeed thinking of something like zstyle ':prezto:module:tmux' auto-start 'no'
zstyle ':prezto:module:tmux' auto-start 'remote' ('ssh')
zstyle ':prezto:module:tmux' auto-start 'local' ('no-ssh')
zstyle ':prezto:module:tmux' auto-start 'yes' I prefer If I didn't make a mistake, it would work like this: if [[ -z "$TMUX" ]] && ( zstyle -t ':prezto:module:tmux' auto-start \
|| [[ -n "$SSH_TTY" ]] && zstyle -m ':prezto:module:tmux' auto-start 'remote' \
|| [[ -z "$SSH_TTY" ]] && zstyle -m ':prezto:module:tmux' auto-start 'local' ); then Edit: gdiscry/prezto@4ca8439 |
Fixed in 07686fa. |
I was playing with SSH and ended up on my own machine (don't ask) which is for me, the only one using the
auto-start
option (tmux
/screen
).The problem is that I ended up with a multiplexer session inside another multiplexer session which is really confusing (even more in my case, where the two sessions were actually the same...).
In general having a multiplexer inside another multiplexer is just plain bad, but when it comes to remote connections there is no way to tell if the user is already in a multiplexer or not.
I guess the best action against that, is disabling
auto-start
for remote connections by default.Then the user will be able to start the multiplexer manually if he wants to.
I understand that some people only use a multiplexer on the server side (so, there is no way that the user could already be in a multiplexer), and want
auto-start
to work properly with a remote access.I added a new option for
screen
andtmux
forcingauto-start
to work with remote connections:This will allow auto-start for an SSH connection on a server.
The documentation and
zpreztorc
have been upgraded