Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: --init-file option
- X-seq: zsh-workers 51428
- From: Kalmár Gergely <kgregory89@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: --init-file option
- Date: Mon, 13 Feb 2023 21:59:44 +0100
- Archived-at: <https://zsh.org/workers/51428>
- In-reply-to: <CAN=4vMpTEL7cQJppNzxO8GPUagS=nu-SN4aYH=ZULEMUtSV8aA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKue2cS2c8TuUgWQxOYjgJ9pEnGb7mx-9RZRD-FnWO2afmvv8g@mail.gmail.com> <CAN=4vMqxKA6yzJgfJZ5cCRT8htPL9pi1NYpeeb+fws04oK3+kQ@mail.gmail.com> <CAKue2cQ0dC3_TyXYVsqWOtBb+Rsv4=1VztBAnKO+iNJ1x=94gQ@mail.gmail.com> <CAH+w=7boGStuymRmwSR55yCys8=qBVASCzO9ks+RvoZFgv7pPQ@mail.gmail.com> <CAN=4vMpTEL7cQJppNzxO8GPUagS=nu-SN4aYH=ZULEMUtSV8aA@mail.gmail.com>
Yes, I could do something similar as what zshi does, but that seems like a suboptimal solution, because it would require a duplication (and indefinite maintenance) of the startup file processing logic in an independent codebase. As the logic is not trivial and has some potential pitfalls as well, it seems to me that implementing the option within Zsh would be the most sound (and perhaps simplest) solution from an engineering and long-term maintenance perspective.
On Mon, Feb 13, 2023 at 9:29 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Create a directory "virtualenv" with the appropriate configuration in
> virtualenv/{.zshenv,.zshrc,.zprofile,.zlogin} and use
> env ZDOTDIR=virtualenv zsh ...
>
> most likely you want virtualenv/.zshrc to be "source $HOME/.zshrc ;
> source xxx" and everything else to merely source the corresponding
> $HOME file.
>
> Adjust for absolute paths as needed. A bit of extra work required if
> you want to preserve an existing $ZDOTDIR before replacing it.
zshi essentially automates this process. It also takes some care of
restoring `ZDOTDIR` before sourcing the real user rc files and
checking `[[ -o rcs ]]` afterwards. There is still one thing that
breaks when using zshi (or doing the same thing manually): global rc
files see the wrong `ZDOTDIR`.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author