From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24622 invoked by alias); 22 Jan 2014 21:22:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18348 Received: (qmail 16463 invoked from network); 22 Jan 2014 21:22:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Wed, 22 Jan 2014 22:22:45 +0100 From: Simon Ruderich To: zsh-users@zsh.org Subject: Re: how can I invoke zsh via screen when logged in via ssh? Message-ID: <20140122212244.GA20502@ruderich.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="=_zucker.schokokeks.org-17004-1390425767-0001-2" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2013-03-19) --=_zucker.schokokeks.org-17004-1390425767-0001-2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 22, 2014 at 02:54:02PM -0500, TJ Luoma wrote: > 1) Would 'zsh' function normally when in screen(1) ? Hello, Of course. I use zsh almost exclusively from within GNU screen. > 2) I've already noticed that emacs keys don't seem to work right, i.e. > control+a does not jump to the beginning of the line, although > control+e jumps to the end of the line. Should I make some adjustment > to `bindkeys` or anything else? GNU screen uses Ctrl-a as "prefix" for all its commands. To send a "real" Ctrl-a to the process running in the screen window, use Ctrl-a a. > 3) What's the 'best' way to invoke screen(1) from .zshenv ? I > already have this: > > [...] This looks a little fragile. To check for a SSH session use one of the SSH_* variables set by sshd, e.g. SSH_CONNECTION or SSH_CLIENT. if [[ -n $SSH_CONNECTION ]]; then # inside a SSH session fi > So I was going to change it to: > > [snip] > > which would, I believe, resume an existing `screen` session if one > existed, but would otherwise just launch `screen` anew. My current solution to automatically launch a GNU screen session or connect to a running one looks like this: if [[ $TERM !=3D dumb && $TERM !=3D linux && -z $STY && -z $TMUX ]]; th= en # Get running detached sessions. session=3D$(screen -list | grep 'Detached' | awk '{ print $1; exit = }') # Create a new session if none is running. if [[ -z $session ]]; then exec screen # Reattach to a running session. else exec screen -r $session fi fi This must be added to the ~/.zshrc on the server. You can easily adapt this for your setup. Just change the condition inside [[ ... ]] to something like [[ -n $SSH_CONNECTION && -z $STY && -z $TMUX ]] This condition is true if inside a ssh connection and neither GNU screen nor tmux is already running. > ps - bonus question: anyone know how to tell screen(1) to _not_ show > its welcome message every time it launches? man screen ;-) Add "startup_message off" to your ~/.screenrc. Regards Simon --=20 + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9 --=_zucker.schokokeks.org-17004-1390425767-0001-2 Content-Type: application/pgp-signature; name="signature.asc" Content-Transfer-Encoding: 7bit Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCgAGBQJS4DakAAoJEJL+/bfkTDL5pqEP/1eVL0O9sDL3f7FuE6l2A7qb xcPhovk2SMMuwPKOZsSi/cGaly8OicKw67FFIAc2QfmzT5rihOO7DAKgbyMbdc2S uAYyQDqo+oiKdxOuoN7AHQ9s44FJADYVVpgI672Wr1yu5+n7NdHaQG2wDVNYtmkM d0vMlDwpvNvuakUCGJZYoJgy2FhJZAK3jRwBRIBQhL0HnoHes4iiaNcKo4yL6dyf b6k2KvzduAp22nUo2LLvqncTUgQnABy5zV+BgcpXbGKMpwV9HWldE9maYcDZ+3l3 dVYGumH7jirCxg+gf4ifMKmRncBO69TlhDHxjpM4Dl1cF1LyixOijr/4ZP9N0Lj0 r9vdxKQ5LI53FGa0rFIz2UQghsVTRjnFyqoKEh1omMcCLs4LjDNbkG8NwgoY/8fZ JMCAt5KsHo8H8U14TD/Ha+XrK7Wb5srF5h4xO7QuGm9v9xwsM7p8SSXYSAUiray+ IAU/olSVuMpjmqHVf+QyPh0x1B018CqcG2/1GH0LqAQdHRUNoTKafaH+I3uHIRu/ BWftfRHpHOE7D53+lQ103bF0AnWg80aCsCbt3y6gOmK/zIOLJGScq2bkv4R25j+Y aP+P29/cQpGdH7PxB+uyuWAhwPrpgR6WeVZigrZaq13zeYBnAdIr82I1ES8dT/l5 dcYIKKq95xd6Ow+pO8jn =vbCJ -----END PGP SIGNATURE----- --=_zucker.schokokeks.org-17004-1390425767-0001-2--