Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Can $PATH look into sub-folders?
- X-seq: zsh-users 26978
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Cc: Zsh MailingList <zsh-users@xxxxxxx>
- Subject: Re: Can $PATH look into sub-folders?
- Date: Wed, 25 Aug 2021 07:57:41 -0700
- Archived-at: <https://zsh.org/users/26978>
- In-reply-to: <CADjGqHuCCN8u2-WG5XAmrrwynh__BDV=PLH4qe+F1akf_7SPBA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CADjGqHuCCN8u2-WG5XAmrrwynh__BDV=PLH4qe+F1akf_7SPBA@mail.gmail.com>
On Wed, Aug 25, 2021 at 7:17 AM TJ Luoma <luomat@xxxxxxxxx> wrote:
>
> My question is whether or not there is an option (a zsh-specific option is fine) which would tell zsh to include sub-folders of $PATH folders without having to explicitly add them all to $PATH.
Not directly, no. There are a couple of ways to approach this that I
can think of:
Zero, the PATH_DIRS approach that PWS already mentioned.
One, if the subdirs contain shell scripts that can be run by zsh, you
can zcompile the entire tree into a bundled .zwc at a level that is in
the path, but that turns them into shell functions which may not be
the behavior you want.
Two, use a command_not_found_handler function to invoke a deeper
search if the initial search doesn't work.
Three, instead of explicitly adding directories to the path, add the
commands themselves with the "hash" builtin.
Four, combine two and three: Locate the command with
command_not_found_handler, and then before running it, update a file
with the location. In precmd, check for modification of that file,
and "hash" the newly-found command.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author