From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27672 invoked from network); 17 Jun 2004 17:21:10 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 17 Jun 2004 17:21:10 -0000 Received: (qmail 8787 invoked from network); 17 Jun 2004 17:10:38 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Jun 2004 17:10:38 -0000 Received: (qmail 20097 invoked by alias); 17 Jun 2004 17:10:09 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7559 Received: (qmail 20077 invoked from network); 17 Jun 2004 17:10:09 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 17 Jun 2004 17:10:06 -0000 Received: (qmail 24120 invoked from network); 17 Jun 2004 16:50:50 -0000 Received: from sj-iport-3-in.cisco.com (HELO sj-iport-3.cisco.com) (171.71.176.72) by a.mx.sunsite.dk with SMTP; 17 Jun 2004 16:50:46 -0000 Received: from sj-core-5.cisco.com (171.71.177.238) by sj-iport-3.cisco.com with ESMTP; 17 Jun 2004 09:52:32 +0000 X-BrightmailFiltered: true Received: from cns-build4.cisco.com (cns-build4.cisco.com [128.107.183.19]) by sj-core-5.cisco.com (8.12.10/8.12.6) with ESMTP id i5HGoBiJ007736; Thu, 17 Jun 2004 09:50:11 -0700 (PDT) Received: (paullew@localhost) by cns-build4.cisco.com (8.11.2/CISCO.WS.1.2) id i5HGoBP27902; Thu, 17 Jun 2004 09:50:11 -0700 (PDT) From: Paul Lew MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16593.52163.379761.15160@cns-build4.cisco.com> Date: Thu, 17 Jun 2004 09:50:11 -0700 To: Jarkko Maja Cc: zsh-users@sunsite.dk Subject: RE: How to clean up path most efficiently? In-Reply-To: <20040617161149.80189.qmail@web60310.mail.yahoo.com> References: <20040617161149.80189.qmail@web60310.mail.yahoo.com> X-Mailer: VM 7.18 under Emacs 21.3.1 X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 >>>>> "Jarkko" == Jarkko Maja writes: Jarkko> Hi, I have tons of directories in my $PATH, but only a Jarkko> handful of them are needed in each my machine; other Jarkko> directories simply do not exist. How could I clean up the Jarkko> non-existing dirs from my $PATH most efficiently? Doing a Jarkko> for loop in ~/.zshrc just for that sounds a bit overkill, Jarkko> but at least I couldn't spot anything like this on man Jarkko> page. This is what I do: * put all paths together in one list * walk thru the list and check the existence of each directory and create a path consists of only the working one * save this in a host specific file, e.g., zpath.$(hostname) * upon zsh startup, if .zshenv is newer than this cached file, then run thru the loop creating the list again. If the cache is newer, just source it to setup the path. This works pretty good except if I update the .zshrc first, then login to update the cache, later I create the missing directory. In this case, the cache is newer than the .zshenv so it will be used without recognizing that the directory is updated. I will have to manually removed the cache file and exec zsh again. Of course, this is because I dont want the burden of access the filesystem with every login. Dont know if anyone has better method.