From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20857 invoked from network); 13 Sep 2007 15:03:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Sep 2007 15:03:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 26079 invoked from network); 13 Sep 2007 15:03:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Sep 2007 15:03:40 -0000 Received: (qmail 14013 invoked by alias); 13 Sep 2007 12:28:34 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11828 Received: (qmail 28921 invoked from network); 13 Sep 2007 11:56:52 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Sep 2007 11:56:52 -0000 Received: (qmail 59786 invoked from network); 11 Sep 2007 18:23:47 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 11 Sep 2007 18:23:39 -0000 Received: from torch.brasslantern.com ([71.116.91.65]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JO200M1886SGB51@vms040.mailsrvcs.net> for zsh-users@sunsite.dk; Sat, 08 Sep 2007 12:20:53 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id l88HKplD032112 for ; Sat, 08 Sep 2007 10:20:52 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id l88HKowu032111 for zsh-users@sunsite.dk; Sat, 08 Sep 2007 10:20:50 -0700 Date: Sat, 08 Sep 2007 10:20:50 -0700 From: Bart Schaefer Subject: Re: preexec hook: possible enhancement? In-reply-to: <200709051905.l85J5cHX003985@pws-pc.ntlworld.com> To: zsh-users@sunsite.dk Message-id: <070908102050.ZM32110@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <200709051905.l85J5cHX003985@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: preexec hook: possible enhancement?" (Sep 5, 8:05pm) On Sep 5, 8:05pm, Peter Stephenson wrote: } } I doubt if there's much joy there... debug traps are called before/after } every command, including in precmd and preexec, so probably far too } often. My thought was to create a TRAPDEBUG function in preexec, and delete it again in precmd. Or at least set/clear a variable in those places so that the function can become an effective no-op when not executing a pipeline from zle. } The only argument to a TRAPDEBUG function is the signal number, which } is meaningless in this case anyway. I think you mean the *line* number? What signal's number would it be? (The argument passed to TRAPDEBUG ought to be documented somewhere, but is not as far as I can tell.) The following appears to work for me; the command is printed only if it runs for at least 1 second, which seems reasonable. Obviously this is pretty expensive -- the shell has the information this is digging out of /proc/*/stat, it just doesn't put it anywhere that TRAPDEBUG can get it. find_fg_job() { emulate -L zsh local x j t reply=() # Find the TTY of the current shell j=( $(/stat do j=() # Process might exit between glob and file read, # so suppress error messages ... j=( $(<$x) ) 2>/dev/null # ... and skip this if we can't read it (( $#j )) || continue # This test skips any sub-shell intermediaries [[ $j[2] == "(zsh)" ]] && continue # Not this shell and on this TTY and in foreground if (( $j[5] != $$ && $j[7] == $t && $j[5] == $j[8] )) then reply=( ${(ps:\0:)"$(