The default bash prompt is set in a system wide file; for a complete explanation of how bash sources its configuration see INVOCATION near the top of man bash
. In short, that system wide file is sourced by ~/.bashrc
; it is pretty obvious.
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Evidentally, what's deciding about the prompt is making the wrong decision. You could dig into that and try to override it by pre-setting some variable, but I recommend against fiddling with /etc/bashrc
and instead simply define your own prompt after that sourcing in ~/bashrc
.
If you search online for bash prompt
you will find copious discussions of it, such as the TLDP How-to. There are actually 4 prompts (see man bash
again) but the standard one is defined by PS1
. This respects standard ANSI escapes; for an explanation of the potential color codes see here. It also uses special escapes to signify things such as the current working directory, user and host name, etc. Those are all defined under PROMPTING in man bash
. An example:
export TERM=xterm-256color
export PS1="\[\033[1;38;5;196m\]\h\[\033[1;48;5;11;38;5;17m\]\u\[\033[0;32m\]\w\[\033[0m\]: "
Gives me:
- Hostname (
\h
) in bold bright red.
- Username (
\u
) in bold dark blue on bright yellow.
- Current working directory (
\w
) in green
But your mileage may vary (in fact, I think the usename bg/fg should be the other way around?). Anyway, it may take a few minutes fooling around; once you've settled on something put it at the end of ~/.bashrc
and it should apply everywhere 24/7.
You can include newlines (\n
) in a prompt, BTW, which is useful if they are long or include the cwd path.
bash
, I'd recommend the fish shell (that bit about "a command line shell for the 90s" is a joke, since it was first released 10 years ago). Its scripting language is not POSIX but as a default interactive shell it is definitely nicer, once you get the hang of things. I use it on the pi and it is fine over ssh; Raspbian has a package (apt-get install fish
, then try it withfish
).