From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28805 invoked by alias); 5 Jul 2016 04:58:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21730 Received: (qmail 21367 invoked from network); 5 Jul 2016 04:58:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Date: Tue, 05 Jul 2016 04:57:53 +0000 From: Daniel Shahaf To: Johan DS Cc: TJ Luoma , Zsh-Users List Subject: Re: Sub-folders in $PATH? Message-ID: <20160705045753.GA8004@tarsus.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Johan DS wrote on Sun, Jul 03, 2016 at 01:26:06 +0200: > On Sun, Jul 3, 2016 at 12:15 AM, TJ Luoma 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))