From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>,
"zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: can we detect the closing of a terminal?
Date: Fri, 04 Sep 2015 20:09:33 +0300 [thread overview]
Message-ID: <1849371441386573@web1m.yandex.ru> (raw)
In-Reply-To: <55E9C085.2090301@eastlink.ca>
04.09.2015, 19:03, "Ray Andrews" <rayandrews@eastlink.ca>:
> 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.
next prev parent reply other threads:[~2015-09-04 17:16 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 [this message]
2015-09-04 21:37 ` Kurtis Rader
2015-09-05 3:07 ` Ray Andrews
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=1849371441386573@web1m.yandex.ru \
--to=kp-pav@yandex.ru \
--cc=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).