More refactoring of PS1 prompt generation.