Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: prompt and ssh
- X-seq: zsh-users 14157
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: prompt and ssh
- Date: Thu, 21 May 2009 09:22:07 -0700
- In-reply-to: <20090521074103.GN27141@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <e7db6e960905190954j7be72739p6b521bca8e90fe7f@xxxxxxxxxxxxxx> <20090519200217.35368.qmail@xxxxxxxxxxx> <20090521074103.GN27141@xxxxxxxxxxxxxxxxxxx>
On May 21, 9:41am, Vincent Lefevre wrote:
} Subject: Re: prompt and ssh
}
} On 2009-05-20 08:02:16 +1200, Atom Smasher wrote:
} > you can test for SSH_CONNECTION, SSH_CLIENT, or SSH_TTY on the far side.
} > i would recommend SSH_CONNECTION.
}
} But this will not work well if you use "screen".
Depending on the platform you're on ...
if grep -q $SSH_CONNECTION[(w)1]\:$SSH_CONNECTION[(w)2] =(netstat -na)
then
print Using SSH_CONNECTION: $SSH_CONNECTION
else
print Invalid SSH_CONNECTION
fi
This "fails" only if you disconnect from screen but leave ssh connected.
Figuring out what the correct values should be and passing them to the
in-screen shell is another matter. The suggestion of a wrapper for
screen that writes a file, combined with checking the file contents in
the precmd or preexec hooks, might do it. E.g.:
screen() {
typeset -pm SSH_\* > ~/.screen_SSH
screen "$@"
}
screen_ssh_precmd() {
source ~/.screen_SSH
}
precmd_functions+=(screen_ssh_precmd)
That is probably a bit too simple -- you could check the file mod time
to avoid sourcing it unnecessarily, and it'd probably be wise check that
you own the file and no one else can write to it or to the directory
it's in, etc.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author