From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12909 invoked by alias); 14 Aug 2011 04:38:01 -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: 16213 Received: (qmail 15457 invoked from network); 14 Aug 2011 04:38:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+bWVEM8q5hpePBq+5qbiGTy5pop6BpgJTYbp/LrunWA=; b=PGoJ51qQTkMa+WkpqwkxRCaImVe8ZoQzY+tq3Dgv2tcQn9U97HlyTycV520IhtTF3N UIVtQx2r2JEji14cV7TkC2wnHiqhjxArbF09NGcY6SZBg9AnshB+Uhmq2VZbYBmIp5F+ ThHrUTqkvq/o9XfmushxysIWGXw3OTmJRX490= MIME-Version: 1.0 In-Reply-To: <20110814040306.GC32168@andrew.cmu.edu> References: <20110813070535.GA10909@soljaris7.fritz.box> <20110814040306.GC32168@andrew.cmu.edu> Date: Sun, 14 Aug 2011 06:37:52 +0200 Message-ID: Subject: Re: Rehash after installs From: Mikael Magnusson To: gi1242+zsh@gmail.com Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 14 August 2011 06:03, wrote: > On Sat, Aug 13, 2011 at 09:05:35AM +0200, Sebastian Tramp wrote: > >>> I'm to the point where I mostly always remember now to rehash after I >>> install anything. But it's still nice to do this automatically when >>> possible. Rather than try to wrap all the system utils that install >>> things, I'd like a reasonably generic way to do it. I'm just checking >>> with the list here to see if this looks like a safe way to do such >>> checking, and make sure there's nothing glaringly wrong about it... >>> >>> typeset -ga precmd_functions >>> rehash-last-install() { fc -l -1 |grep -q install && { print >>> rehash-ing; rehash } } >>> precmd_functions+=rehash-last-install >>> >>> Basically, this just looks at the last command (via fc) to see if >>> there was an "install" somewhere in it, and runs itself after every >>> command. It's going to rehash more often than necessary (false >>> positives), but I can't think of why that would be a bad thing since >>> rehashing looks pretty cheap. >> >> On debian, "dpkg -i" will also install packages (beside apt-get), >> and especially on ubuntu, users often utilize synaptic and the >> software-center for that (but imho these graphical installers can be >> ignored for the reason that their users do not tend to have a shell >> always open somewhere) > > Another (perhaps nicer) solution would be to "rehash" if command > completion failed, and then retry completion after that. > > This way even with a GUI installation program you'll get current > completion info. I've no idea how to implement it though; so if someone > does it (or has already done it), please let me know. You mean something like zstyle ':completion:*' rehash true ? -- Mikael Magnusson