From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26421 invoked by alias); 14 Aug 2011 04:29:17 -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: 16212 Received: (qmail 6032 invoked from network); 14 Aug 2011 04:29:06 -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=-1.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 128.2.11.95 is neither permitted nor denied by SPF record at _spf.google.com) Date: Sun, 14 Aug 2011 00:03:07 -0400 From: gi1242+zsh@gmail.com To: zsh-users@zsh.org Subject: Re: Rehash after installs Message-ID: <20110814040306.GC32168@andrew.cmu.edu> References: <20110813070535.GA10909@soljaris7.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110813070535.GA10909@soljaris7.fritz.box> User-Agent: Mutt/1.5.18 (2008-05-17) X-PMX-Version: 5.5.9.388399, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.5.19.222118 X-SMTP-Spam-Clean: 33% ( RDNS_SUSP_FORGED_FROM 3.5, FORGED_FROM_GMAIL 0.1, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1600_1699 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_REAL_NAME 0, NO_URI_FOUND 0, RDNS_BROADBAND 0, RDNS_GENERIC_POOLED 0, RDNS_POOLED 0, RDNS_SUSP 0, RDNS_SUSP_GENERIC 0, RDNS_SUSP_SPECIFIC 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CP_NOT_1 0, __CT 0, __CT_TEXT_PLAIN 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __PHISH_SPEAR_STRUCTURE_1 0, __RDNS_BROADBAND_5 0, __RDNS_POOLED_11 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __USER_AGENT 0) X-SMTP-Spam-Score: 33% X-Scanned-By: MIMEDefang 2.60 on 128.2.11.95 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. GI -- Energizer Bunny arrested - charged with battery.