Console Colour – prompts and tools

by hobbitalastair

Pretty :)

Colourised dmesg output

Throughout the last week, I have been working on adding colour to the my console. I like colour :).

More colour :)

Colour in grep

Colour in a console is achieved through using escape codes. Escape codes are commands that are interpreted by the console, and are used to provide extra features like underlined text, blinking text, and colour.

Some standard UNIX commands provide colour, at least in Arch Linux:

  • grep
  • dmesg
  • top

For example:

grep --color <expression>

will colourise anything that matches ‘expression’.

My prompt now has colour as well:

More colour :)

Colour in the bash prompt

Getting colour in the bash prompt was slightly challenging, as I added the script for colourising the prompt in my ‘/etc/profile.d/terminal’ file. In Arch Linux, this is overridden if a /etc/bash.bashrc file exists, as the bashrc file is sourced after ‘/etc/profile.d/*’. I fixed this by adding a patch for my systems, that blanks out the bashrc file.

I am unsure about how good this approach is, but for now it will do.

I’ve also added colour to my console shell scripts:

Note that there is a few bugs :(

Colour in patchman, using cli_helper

Advertisements