* Sub-folders in $PATH?
@ 2016-07-02 22:15 TJ Luoma
2016-07-02 23:26 ` Johan DS
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: TJ Luoma @ 2016-07-02 22:15 UTC (permalink / raw)
To: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
Is there an option to have subfolders in a $PATH folder searched as well?
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-folders in $PATH?
2016-07-02 22:15 Sub-folders in $PATH? TJ Luoma
@ 2016-07-02 23:26 ` Johan DS
2016-07-04 9:28 ` Roman Neuhauser
2016-07-02 23:50 ` Nikolay Aleksandrovich Pavlov (ZyX)
[not found] ` <CAEyXbzcge3DWff-uFy4+ZL3Nbbbqs+FyYcBOMVkBLugv7--jzg__46346.1699583151$1467502045$gmane$org@mail.gmail.com>
2 siblings, 1 reply; 6+ messages in thread
From: Johan DS @ 2016-07-02 23:26 UTC (permalink / raw)
To: TJ Luoma; +Cc: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
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
On Sun, Jul 3, 2016 at 12:15 AM, TJ Luoma <luomat@gmail.com> wrote:
> Is there an option to have subfolders in a $PATH folder searched as well?
>
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-folders in $PATH?
2016-07-02 22:15 Sub-folders in $PATH? TJ Luoma
2016-07-02 23:26 ` Johan DS
@ 2016-07-02 23:50 ` Nikolay Aleksandrovich Pavlov (ZyX)
[not found] ` <CAEyXbzcge3DWff-uFy4+ZL3Nbbbqs+FyYcBOMVkBLugv7--jzg__46346.1699583151$1467502045$gmane$org@mail.gmail.com>
2 siblings, 0 replies; 6+ messages in thread
From: Nikolay Aleksandrovich Pavlov (ZyX) @ 2016-07-02 23:50 UTC (permalink / raw)
To: TJ Luoma, Zsh-Users List
03.07.2016, 01:16, "TJ Luoma" <luomat@gmail.com>:
> Is there an option to have subfolders in a $PATH folder searched as well?
>
> 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
If script names are unique you may employ command_not_found_handler function to do this job. Note though that this will work like you have all subfolders after all folders in $PATH, if e.g. there are executables `/usr/bin/scripts/foo` and `/usr/local/bin/foo` and `PATH=/usr/bin:/usr/local/bin` then implementing this functionality via command_not_found_handler will find `/usr/local/bin/foo` before considering `/usr/bin/scripts/foo`.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-folders in $PATH?
2016-07-02 23:26 ` Johan DS
@ 2016-07-04 9:28 ` Roman Neuhauser
0 siblings, 0 replies; 6+ messages in thread
From: Roman Neuhauser @ 2016-07-04 9:28 UTC (permalink / raw)
To: Johan DS; +Cc: TJ Luoma, Zsh-Users List
# victor3xray@gmail.com / 2016-07-03 01:26:06 +0200:
> 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
you could replace both exports with
path+=(
{/usr/local,/usr,}/bin
{/usr/local,/usr,}/sbin
~/bin/*(/N)
)
--
roman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-folders in $PATH?
[not found] ` <CAEyXbzcge3DWff-uFy4+ZL3Nbbbqs+FyYcBOMVkBLugv7--jzg__46346.1699583151$1467502045$gmane$org@mail.gmail.com>
@ 2016-07-05 4:57 ` Daniel Shahaf
2016-07-05 9:14 ` Roman Neuhauser
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2016-07-05 4:57 UTC (permalink / raw)
To: Johan DS; +Cc: TJ Luoma, Zsh-Users List
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@gmail.com> 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))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-folders in $PATH?
2016-07-05 4:57 ` Daniel Shahaf
@ 2016-07-05 9:14 ` Roman Neuhauser
0 siblings, 0 replies; 6+ messages in thread
From: Roman Neuhauser @ 2016-07-05 9:14 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Johan DS, TJ Luoma, Zsh-Users List
# d.s@daniel.shahaf.name / 2016-07-05 04:57:53 +0000:
> Johan DS wrote on Sun, Jul 03, 2016 at 01:26:06 +0200:
> > 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))
yeah, sorry about that, i *meant* to use recursive glob.
--
roman
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-05 9:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-02 22:15 Sub-folders in $PATH? TJ Luoma
2016-07-02 23:26 ` Johan DS
2016-07-04 9:28 ` Roman Neuhauser
2016-07-02 23:50 ` Nikolay Aleksandrovich Pavlov (ZyX)
[not found] ` <CAEyXbzcge3DWff-uFy4+ZL3Nbbbqs+FyYcBOMVkBLugv7--jzg__46346.1699583151$1467502045$gmane$org@mail.gmail.com>
2016-07-05 4:57 ` Daniel Shahaf
2016-07-05 9:14 ` Roman Neuhauser
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).