From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14618 invoked by alias); 13 Aug 2011 07:05:46 -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: 16210 Received: (qmail 19645 invoked from network); 13 Aug 2011 07:05:43 -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.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at informatik.uni-leipzig.de does not designate permitted sender hosts) Date: Sat, 13 Aug 2011 09:05:35 +0200 From: Sebastian Tramp To: Micah Elliott Cc: zsh-users@zsh.org Subject: Re: Rehash after installs Message-ID: <20110813070535.GA10909@soljaris7.fritz.box> Mail-Followup-To: Micah Elliott , zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: University of Leipzig X-PGP-Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE8093B579D601B44 X-FOAF: http://sebastian.tramp.name User-Agent: Mutt/1.5.21 (2010-09-15) On Fri, Aug 12, 2011 at 11:53:00PM -0700, Micah Elliott wrote: > I've found that most tools don't rehash after they install something. > aptitude is guilty (if you want to call it that), but other tools like > "gem" are more friendly (well, I believe RVM is the one providing this > wrapper.) > > % whence -f gem > gem () { > local result > command gem "$@" > result="$?" > hash -r # Update so newly installed util is now active! > return $result > } > > Cool idea! > > 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. Hi Micah, This is a nice idea. 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) Best regards Sebastian Tramp -- Sebastian Tramp - Department of Computer Science; University of Leipzig WebID: http://sebastian.tramp.name Tel. (Fax): +49 341 97 323-66 (-29)