14

Is it possible to color the prompt ("user@host:~/dir/$") in Bash? Some commands generate a lot of output and it's sometimes hard to find where it started. Coloring would help a lot.

1
29

Found an easy way to do it:

Uncomment force_color_prompt=yes in ~/.bashrc.

2
  • 1
    That's certainly the easiest way :) Nov 19 '10 at 7:30
  • I absolutely overlooked this option in the ~/.bashrc! Thanx anyways!
    – Ubuntuser
    May 4 '11 at 10:54
0

Bashish is a theme engine for the console; check some screen shots here :-)

It's easy to install:

  1. Click on the download link on the website
  2. get the deb for Ubuntu
  3. double-click the downloaded file and Software center will install it for you.

After that, close any open terminals and type:

bashish list

to get a list of already built themes.

Have fun :-)

0

A catch-all alternative to the other solutions:

if [ $(which dircolors) ]
then
  if [ -r ~/.dircolors ]
  then
    eval "$(dircolors -b ~/.dircolors)"
  else
    eval "$(dircolors -b)"
  fi
  export color_support=true
fi

Additionally, you could enable colors in common commands such as ls and grep.

if [ "$color_support" = true ]
then
  alias ls="ls --color=auto"
  alias grep="grep --color=auto"
fi
2
  • In what files should that code be stored? May 5 '18 at 22:02
  • I suggest .bashrc for simplicity. :)
    – user45853
    May 5 '18 at 22:09

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.