Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: How to clean up path most efficiently?



>>>>> "Jarkko" == Jarkko Maja <jarkko1982@xxxxxxxxx> 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.



Messages sorted by: Reverse Date, Date, Thread, Author