From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: can we detect the closing of a terminal?
Date: Fri, 04 Sep 2015 20:07:23 -0700 [thread overview]
Message-ID: <55EA5C6B.4030608@eastlink.ca> (raw)
In-Reply-To: <CABx2=D-tdE62Fz9s8T0yWpcutVtF_O4S2ErrZfYMam5gSbPTKQ@mail.gmail.com>
Kurtis, ZyX:
On 09/04/2015 02:37 PM, Kurtis Rader wrote:
>
>> I'm guessing that by "open a terminal" you mean start an interactive shell.
When I fire up an xterm it comes with a zsh shell pre loaded. That's all
I know. In each one of them you can "echo $TTY" and it will report
"/dev/pts/2" or some other number than '2'. I can have a dozen of them
open, and when I close one I'd like some way of letting the other
terminals know it. Reason being that each terminal has an associated
variable 't[number of the terminal]' set to its $PWD and I do stuff
like: 'cp * $t10' where '$t10' is the current directory on terminal
'/dev/pts/10' and which does horrible things is terminal #10 has been
closed so I want some way of killing '$t10' when that happens.
>> The distinction is important when you consider cases such as using ssh to
>> log into another system or starting an xterm that simply displays the
>> output of a command (possibly a zsh script). Or consider the case where
>> you're using a program such as "screen" or "tmux" to multiplex access to a
>> shell. In that case it is normal to create a new "terminal" and connect to
>> an existing tmux session. Then close that "terminal" while leaving the tmux
>> session, and thus the interactive shell running within it, still running.
Yikes, there's more things you mention there than I even know exist ;-)
>> The simplest solution is to create a $HOME/.zlogout script (see "man zsh").
>> Other solutions such as a TRAPEXIT function or using the trap command to
>> handle SIGHUP and SIGTERM are also possible. The trap command solution is
>> the most portable.
>>
Between what you say and ZyX's comments, there's a few things to chew
on, tho it's mostly way over my head still but I'll give it a dangle and
thrash.
next prev parent reply other threads:[~2015-09-05 3:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-30 19:13 zsh 5.1 released [user] Peter Stephenson
2015-09-04 16:02 ` can we detect the closing of a terminal? Ray Andrews
2015-09-04 17:09 ` ZyX
2015-09-04 21:37 ` Kurtis Rader
2015-09-05 3:07 ` Ray Andrews [this message]
2015-09-05 4:31 ` Kurtis Rader
2015-09-05 14:27 ` Ray Andrews
2015-09-06 16:43 ` zsh 5.1 released [user] Ray Andrews
2015-09-06 16:55 ` Axel Beckert
2015-09-06 16:57 ` Axel Beckert
2015-09-06 17:13 ` Ray Andrews
2015-09-06 19:37 ` Axel Beckert
2015-09-06 19:58 ` Ray Andrews
2015-09-08 1:55 ` Ray Andrews
2015-09-06 17:08 ` Ray Andrews
2015-09-06 16:50 ` syntax question Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55EA5C6B.4030608@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).