How to create a custom terminal prompt?

Here is a thread from this forum.