From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: -C -like option to change CWD on startup
Date: Thu, 2 Feb 2023 10:05:10 +0100 [thread overview]
Message-ID: <CAN=4vMpm=cHbt05rOQZLkRZctKc=t+jocZ4rWsgmziBs_sK5Bw@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVDN+HfQ=qFatNcWFiNRiTMtpAi6FXhXNqdQ1SRxHj1vcw@mail.gmail.com>
On Thu, Feb 2, 2023 at 9:57 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hi,
> make and git have the -C option which works like:
> (
> builtin cd -q $COPT
> git/make "$@"
> )
>
> I think that it is very useful, because no lengthy subshell is needed. Zsh doesn't have such option, could it be added? It's pitty that -C is already used by NO_CLOBBER, but maybe some other letter is free (I didn't found any)?
You can do this:
zsh-in-dir() ( builtin cd -q -- "$1" && builtin exec zsh "${@:2}" )
This forks and execs once, the same as if there was a native `-C dir` option.
Note that your original code has the same performance thanks to an
optimization in zsh. The second fork is elided.
Roman.
next prev parent reply other threads:[~2023-02-02 9:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 8:55 Sebastian Gniazdowski
2023-02-02 9:05 ` Roman Perepelitsa [this message]
2023-02-02 9:31 ` Sebastian Gniazdowski
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='CAN=4vMpm=cHbt05rOQZLkRZctKc=t+jocZ4rWsgmziBs_sK5Bw@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=sgniazdowski@gmail.com \
--cc=zsh-workers@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).