One thing you could do is use commonly named vars to define the terminal escapes specific to each shell's interpretation in their own sourced script, then bring it all together at the end in a single prompt:
~/.zshrc
esc1='SPECIFIC TO ZSH'
esc2='SPECIFIC TO ZSH'
. ~/.common_prompt
~/.bashrc
esc1='SPECIFIC TO BASH'
esc2='SPECIFIC TO BASH'
. ~/.common_prompt
~/.dashrc
esc1='SPECIFIC TO DASH'
esc2='SPECIFIC TO DASH'
. ~/.common_prompt
~/.common_prompt
esc3='COMMONLY INTERPRETED ESCAPE SEQUENCE'
PROMPT_COMMAND='eval PS1=\"printf %b "$esc1" "$esc2" "$esc3"\"'
And if one shell is likely to do more with the prompt than another, just .dot
sourcing .common_prompt
file doesn't have to be the end. So if zsh
is going to do more processing than dash,
for instance - because it will - you just take it from there:
~/.zshrc
esc1='SPECIFIC TO ZSH'
esc2='SPECIFIC TO ZSH'
. ~/.common_prompt
_more_processing "${PROMPT_COMMAND}"