In a shared cluster I work on, the environment settings for new accounts does not include a prompt setting, as far as I can tell. In particular,
PS1 is not set. And yet, when one logs into a new account, one gets a rather fancy prompt, featuring the username and the basename of the current directory.
I want to save this prompt (e.g. in an environment variable like
ORIGINAL_PS1) before replacing it with my preferred prompt, so that I can restore it later if desired1.
How can I extract the prompt definition from the current prompt?
I am primarily interested in the answer to this question for
bash, but if there's something analogous for
zsh, please let me know.
1 I rather like the default prompt, but for everyday use I prefer to use a "
git-aware" prompt. That said, although I find the latter extremely helpful 99.999% of the time, ocassionally I
cd to a
git repo that is sufficiently messed up that it causes the prompt's generation to become unacceptably slow. For those rare circumstances, I'd like to be able to run