Is it possible to run new zsh
or bash
shell with custom PS1
set from command line? It should overwrite the default theme set by .bashrc
and .zshrc
respectively.
I'm talking about something like zsh --myprompt="yes master? >"
EDIT: I do not want to affect any user-side configuration files. I want it to work for any user with any configuration.
Create your own "shim" rcfile that's available to your users then call that with the --rcfile
option (for bash) or --rcs
option (for zsh). This should source the user's rcfile first. For example, let's call this /usr/local/share/.fancypromptrc. In bash this might look like:
source "$HOME/.bashrc"
export PS1="DOLLAZ $"
And in zsh this might look like:
source "${ZDOTDIR:-$HOME}/.zshrc"
export PS1="DOLLAZ $"
Then the user would start bash with bash --rcfile /usr/local/share/.fancypromptrc
. In zsh it would be zsh --rcs /usr/local/share/.fancypromptrc
.
This way the user doesn't have to modify their rcfile and if they are already setting PS1 it will still be replaced. The only time I can imagine this not working is if they have a PROMPT_COMMAND that overwrites the PS1, or something similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With