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

Re: How to clean up path most efficiently?



>>>>> "Peter" == Peter Stephenson <pws@xxxxxxx> writes:

    >> I have tons of directories in my $PATH, but only a handful of
    >> them are needed in each my machine; other directories simply do
    >> not exist. How could I clean up the non-existing dirs from my
    >> $PATH most efficiently?  Doing a for loop in ~/.zshrc just for
    >> that sounds a bit overkill, but at least I couldn't spot
    >> anything like this on man page.

    Peter> It should be as simple as:

    Peter> path=($^path(N))

This is cool.  Few questions for efficiency here:

(1) which one is more efficient?  The parameter expansion with
    NULL_GLOB or read in the ready list from disk?  Originally I setup
    the path with a loop that will check for [[ -d $dir ]] but the
    speed is greatly improved with the cached file.  Since most
    of the dir in our path are auto mounted, caching seems the
    better way.

(2) when is zsh rehash the path?  vared path?  path=(...) ?  If
    path is rehased everytime path is updated, then will it be
    bad practice to do:

    PATH=a:b:c
    PATH=$PATH:d:e
    PATH=$PATH:f:g

    This is to make the script fit on terminal width but will it
    be costly?

TIA.




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