Create prompt using a state machine

Create the prompt using a loop rather than running multiple text
substitution commands. That will be more flexible, and will also load
attributes like user name and host name when those are actually needed.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>