From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11386 invoked by alias); 4 Sep 2015 17:16:03 -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: 20510 Received: (qmail 23620 invoked from network); 4 Sep 2015 17:16:01 -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=-0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,FSL_HELO_BARE_IP_2 autolearn=no autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1441386574; bh=Nw3jCM8KDM9TM9yvR8Tpd/CpI2anMXpP49V0obUB8Xo=; h=From:To:In-Reply-To:References:Subject:Date; b=HEFfBck8yFIsVkLq+smsCF3rdsNZbvS0UYJdXLQElBejBSjAZq3r1Ol8rUaznrqn9 jrt331EiP8sgpU3CuxpeZlSfmr6YO3xehQix5uLk6NR+TDt77w31P7QPTtdz0qjweC I5CZwBs2aW4I/+yz0aKP0ULajeKuNWD4ac08YI3U= From: ZyX To: Ray Andrews , "zsh-users@zsh.org" In-Reply-To: <55E9C085.2090301@eastlink.ca> References: <20150830201324.309d36b0@ntlworld.com> <55E9C085.2090301@eastlink.ca> Subject: Re: can we detect the closing of a terminal? MIME-Version: 1.0 Message-Id: <1849371441386573@web1m.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 04 Sep 2015 20:09:33 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 04.09.2015, 19:03, "Ray Andrews" : > Gentlemen: > > 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. You can use `trap` command for this: trap 'command' EXIT (alternative: define TRAPEXIT() function), needs to be defined outside of functions. `man zshbuiltins`, documentation for `trap` built-in also references `zshexit` hook, so it is probably better to use function my-zshexit-hook() { your code here } zshexit_functions+=( my-zshexit-hook ) . But documentation for this hook says that this hook is “Executed at the point where the main shell is about to exit normally.”: note “normally”. When trying to use this do some tests, maybe you need this trap *and* some trap like TRAPHUP() function, I have not ever needed this.