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

Re: How to clean up path most efficiently?



On 6/17/04 12:34 PM, "Peter Stephenson" <pws@xxxxxxx> wrote:

> Jarkko Maja wrote:
>> 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.

yeah I did something like this a long time ago, but since it rarely changes
per-machine, it was overkill

PATH=""

for dir in /usr/bin /bin /sbin /usr/local/sbin /usr/local/bin $HOME/bin
do

    if [[ -d $dir ]]
    then

        PATH=$dir:$PATH

    fi

done

(Note: that list of dirs is in reverse order of preference due to the way
the loop is put together, to avoid ':' as the first character in the PATH
string.


> It should be as simple as:
> 
> path=($^path(N))

Does that go through the current $PATH and delete all the folders that
aren't listed in there?

Is it supposed to be lowercase?

TjL




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