zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: TJ Luoma <luomat@gmail.com>
Cc: Zsh MailingList <zsh-users@zsh.org>
Subject: Re: Can $PATH look into sub-folders?
Date: Wed, 25 Aug 2021 07:57:41 -0700	[thread overview]
Message-ID: <CAH+w=7ZjS1VLQ9k0z2p0yNBNOOZoMs_DkN1mxSVuPW7AW+ahgQ@mail.gmail.com> (raw)
In-Reply-To: <CADjGqHuCCN8u2-WG5XAmrrwynh__BDV=PLH4qe+F1akf_7SPBA@mail.gmail.com>

On Wed, Aug 25, 2021 at 7:17 AM TJ Luoma <luomat@gmail.com> 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.


      parent reply	other threads:[~2021-08-25 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 14:17 TJ Luoma
2021-08-25 14:51 ` Peter Stephenson
2021-08-25 15:36   ` TJ Luoma
2021-08-30 14:20   ` zzapper
2021-08-30 15:32     ` Bart Schaefer
2021-08-25 14:57 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZjS1VLQ9k0z2p0yNBNOOZoMs_DkN1mxSVuPW7AW+ahgQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=luomat@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).