I wish to set a custom color for the hostname portion of my command line prompt (in bash).
In my .bashrc
file, the default command line prompt is:
PS1='[\u@\h \W]\$ '
To colorize the hostname only, I came up with this prompt:
PS1='[\u@\e[40;36m\h\e[0m \W]\$ '
I used different colors for each host I work on. The colorizing part seems to be working as expected. However, with the prompt above, navigation on the command line becomes dysfunctional. For example, at times I cannot move the cursor to the beginning or end of the line. If I switch back to the default prompt, everything works correctly again.
What's wrong with my colorized prompt? How can I properly specify a color for the hostname only?
It should not matter for this question, but I'm running Arch Linux KDE and I work in Konsole.