Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: --init-file option



Thank you! Yes, I'm already using the -c 'source xxx; command' approach with Bash/fish, and you are right, it should work with Zsh too of course. Nonetheless, the problem of starting Zsh with an activated virtual environment remains.

I suppose the next question is if the maintainers would consider adding this feature to Zsh to support use cases like these, just as Bash/fish do (which is why I thought writing to zsh-workers instead of zsh-users was perhaps going to be more appropriate).

Best,
Gergely

On Mon, Feb 13, 2023 at 12:24 PM Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
On Mon, Feb 13, 2023 at 11:58 AM Kalmár Gergely <kgregory89@xxxxxxxxx> wrote:
>
> I was wondering if there is an equivalent to Bash's --init-file
> option or fish shell's --init-command option in Zsh or if one can
> hack around to achieve the same effect. I would need to be able to
> source a virtual environment activation file after the Zsh startup
> files were processed (but before a command is executed) in order to
> be able to start a shell or run commands inside a Python virtual
> environment.

If you are executing a script or a command, then instead of this:

    zsh foo
    zsh -c 'foo'

you can do this:

    zsh -c 'source /path/to/your/file; foo'

If you need to start an interactive zsh that sources an extra file
after the usual startup files, and if you cannot modify any of the
standard startup files, then https://github.com/romkatv/zshi or
something like it is the only option. Disclaimer: It's my project but
I'm not using this code myself.

P.S.

This question is more suitable for zsh-users than zsh-workers.


Messages sorted by: Reverse Date, Date, Thread, Author