Zsh Mailing List Archive
Messages sorted by:
Re: --init-file option
- X-seq: zsh-workers 51432
- From: Kalmár Gergely <kgregory89@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: --init-file option
- Date: Tue, 14 Feb 2023 11:18:46 +0100
- Archived-at: <https://zsh.org/workers/51432>
- In-reply-to: <CAH+w=7aRM++g6yuWbPBaU-n2-uKdAu_=ih60zwVMeF24XF+iGQ@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> <CAKue2cRDk0j_4jPmQd6rQxb3utc5N=BvS0jDSrOXVASLbDcyqQ@mail.gmail.com> <CAH+w=7aRM++g6yuWbPBaU-n2-uKdAu_=ih60zwVMeF24XF+iGQ@mail.gmail.com>
I meant keeping it in a codebase independent of Zsh's.
You are right, bash's --init-file does replace bashrc, so I have to source that too in my activation script. For my use case I just want to start a new shell that works the same to the user as when they start a vanilla shell, with the exception that the virtual environment activation file is sourced. The activation file sets/modifies a bunch of environment variables (e.g. PATH, PYTHONHOME and PS1) and changes the working directory. To me fish shell's --init-command is the most elegant approach, but I can also live with the same approach as what bash does – in which case I only would need to source .zshrc in my activation script and not meddle with ZDOTDIR (which might have unintended side-effects, like what Roman mentioned regarding the startup files seeing the modified ZDOTDIR instead of what the user potentially sets it to be).
On Mon, Feb 13, 2023 at 12:59 PM Kalmár Gergely <kgregory89@xxxxxxxxx> wrote:
> 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.
I don't follow that at all. You're keeping the file for --init-file
somewhere now (I presume), so why would pointing ZDOTDIR at it require
a new codebase?
Anyway "bash --init-file" replaces (both global and user) bashrc
rather than run the file after them, which doesn't match what you
originally asked for. Does it in fact do what you want?
Does your file need to create internal variables or functions, or is
it just populating the environment?
Messages sorted by: