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?)?


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\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

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:


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

  • Does that work for the terminal application? Mar 6 '16 at 20:59
  • @MarioKamenjak It works for all terminals that support coloring through ANSI color escape sequences (for example the console, gnome-terminal and xterm, but most if not all xterm-based terminals will likely support that, though the palette could be more or less extensive). I suppose you're referring to Terminal (which is gnome-terminal), so if that's the case yeah, it will work for Terminal.
    – kos
    Mar 6 '16 at 21:26
  • I had to uncomment force_color_prompt first. Anyway, it works now. Here is my color scheme: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u\[\033[01;36m\]@\[\033[01;36m\]\h\[\033[00m\]:\[\033[00m\]\w\[\033[00m\]\$' Mar 7 '16 at 15:32
  • This helped as well: cyberciti.biz/faq/… I will accept your answer now. Mar 7 '16 at 15:32
  • @MarioKamenjak Which terminal? It shouldn't be necessary in gnome-terminal / xterm (in fact my prompt is colored, but force_color_prompt=yes is still commented).
    – kos
    Mar 7 '16 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.