From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 902 invoked by alias); 5 Sep 2015 03:37:30 -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: 20513 Received: (qmail 1210 invoked from network); 5 Sep 2015 03:37:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=H2JqDnfXgObE0ECzEBcjTg==:117 a=H2JqDnfXgObE0ECzEBcjTg==:17 a=IkcTkHD0fZMA:10 a=PEfZtTF29h98njvX1SIA:9 a=WlMJr5i3DVX8JW6t:21 a=7u3ikKlh8PN1ViHB:21 a=QEXdDO2ut3YA:10 Message-id: <55EA5C6B.4030608@eastlink.ca> Date: Fri, 04 Sep 2015 20:07:23 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: can we detect the closing of a terminal? References: <20150830201324.309d36b0@ntlworld.com> <55E9C085.2090301@eastlink.ca> In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit 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.