From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27717 invoked by alias); 4 Sep 2015 21:38:06 -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: 20512 Received: (qmail 5972 invoked from network); 4 Sep 2015 21:38:04 -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,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=p6JSGGcucCkQojNSEiPaYDt5OlfbBaOWuz44xQMZSn8=; b=QLcvLnoZNgx8cuFruhzSjcR2DPbkxxiaaIZt5ji24yyZxSSZZJC7Lvk6wno6HiS6JD 21Bh/E9rTXAopXyyN3/UU6qxvtCwM9MUBEBTLpO3f/dC2hUwLUdDYP1s431Q0KlpZG7Q 9sr5WjOpA8519XKKUT3NfQh9p0m0mczED5+Q0XaikoTZxt1eqk6889RyRJ2sOTzhad1P QC5Vj0XmDyiBoRnnspxNEfCIxa8AyiTqNpYuANHp2Ek0LDxhj5/ZrGSrGiOqQeECJFgz CD58qvaHrisOWNUEog39QNbehp47diAjyVV3kCoQTnycbr365OMke/6WI4VAMBEg4dcH EQtw== X-Gm-Message-State: ALoCoQlHQZHcHsF0x2OECOCLH2tUkYUFhQWw1Y9s+u/Zd+qWyO6HXjed4bQMog3Wiuo75Jc4Lykd MIME-Version: 1.0 X-Received: by 10.112.11.233 with SMTP id t9mr5542306lbb.104.1441402679703; Fri, 04 Sep 2015 14:37:59 -0700 (PDT) In-Reply-To: <55E9C085.2090301@eastlink.ca> References: <20150830201324.309d36b0@ntlworld.com> <55E9C085.2090301@eastlink.ca> Date: Fri, 4 Sep 2015 14:37:59 -0700 Message-ID: Subject: Re: can we detect the closing of a terminal? From: Kurtis Rader To: Ray Andrews Cc: Zsh Users Content-Type: multipart/alternative; boundary=001a11c3b9aab3d37e051ef2b6c1 --001a11c3b9aab3d37e051ef2b6c1 Content-Type: text/plain; charset=UTF-8 On Fri, Sep 4, 2015 at 9:02 AM, Ray Andrews wrote: > Whenever I open a terminal I have a mechanism for passing to it knowledge > of the current $PWD of any other open terminals. It's cumbersome but it > works. Problem is that it's a one way thing in that when a terminal > closes, that information is not passed, so there is orphan information. Is > there some 'pre-close()' function for terminals? Sort of a suicide note? > Or it might be about the same thing to have a function that's called before > a shell exits 'zsh-pre-close()' , tho of course there can be several layers > of shells in one terminal, but I guess that one can test for the 'zero' > level shell in any given terminal. I'll bet there is one for the shell, > but for the terminal that might be wishing upon a star. > I'm guessing that by "open a terminal" you mean start an interactive shell. 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. 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. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --001a11c3b9aab3d37e051ef2b6c1--