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

Re: Sub-folders in $PATH?



Johan DS wrote on Sun, Jul 03, 2016 at 01:26:06 +0200:
> On Sun, Jul 3, 2016 at 12:15 AM, TJ Luoma <luomat@xxxxxxxxx> wrote:
> 
> > Is there an option to have subfolders in a $PATH folder searched as well?

Consider: setopt PATH_DIRS

> > For example, if I wanted to put some folders in /usr/local/bin/scripts/
> > without explicitly adding /usr/local/bin/scripts/ to $PATH
> > (assuming  /usr/local/bin/ was already in there).
> >
> > TJ
> 
> Hi
> I have this in my .zshenv
> 
> export
> PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:
> [[ -d ~/bin ]] && export PATH=${PATH}:$(find ~/bin -type d | tr '\n' ':' |
> sed 's/:$//') #include all ~/bin/subdirs

Another way of doing the same thing:

    path+=(
      /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbin 
      ~/bin/**/*(/N)
    )

(unlike Roman's solution this uses ** to be equivalent to the find(1))



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