2

When using the terminal, I want both my username and my hostname to have separate color schemes. Is that possible with Ubuntu's default terminal emulator(if not, is it possible in terminator?)?

muru
  • 207,228

1 Answers1

3

You could wrap \h in, e.g., \[\033[01;31m\] and \[\033[00m\] in ~/.bashrc's $PS1 definition to make the host red; \[\033[00m\], which resets all the attributes, is already there in the default prompt, so you won't really need it, and I suggest commenting out $PS1's definition and adding a line right after rather than editing the current $PS1's definition for an easy rollback:

if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\[\033[01;31m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

This should work out-of-the-box on e.g. gnome-terminal; on xterm (and I'd guess in general on xterm-based terminals), you'll also have to uncomment this line:

#force_color_prompt=yes

You can check out other available colors e.g. here.

kos
  • 41,268