Is it possible to start an interactive zsh session with a specific prompt without modifying a configuration file?

I tried things like that:

zsh -c 'autoload -U prompt; prompt adam1; zsh -i'

But that obviously doesn't work as the ending zsh -i starts a fresh new interactive session.

A solution to this may be the use of an option telling zsh to load a specific configuration file (again, without modifying any existing default configuration file such as ~/.zshrc), something like:

zsh -i --configuration=~/path/to/foo.zshrc

But I don't know and can't find such an option.


I found an answer in this question: Invoke zsh, then *source* another file (while entering interactive mode)

The solution is to write the commands I want to run in a .zshrc file in any folder I want, for example:


autoload -Uz prompt
prompt adam1

And start zsh with a modified ZDOTDIR environment variable:

ZDOTDIR=~/path/to/foo zsh

I flagged my question as duplicate of the one I linked and upvoted the question and it's answer, sorry for the noise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.