Kubuntu

How to change Terminal colors.

This How To uses some of the stuff described in The Basics.
The following sites helped out in writing this How to:
Linux Self Help
Life Hacker

Changing the Terminal colors to something that looks interesting or even l33t.

Here is the “boring” version:
terminal_clean.png

Now I’ve already changed the Schema. (Settings->Schema->White on Black)
I just like stuff to be on a black background. 😀

So how do we change the colors like almost everything in Linux Terminal has a config file it’s located at:

~/.bashrc

Now we have to write some functions to take care of the coloring.  Open ~/.bashrc in nano:

nano ~/.bashrc

Add the following code to the end of this file:

function elite
{

local GRAY="[33[1;30m]"
local LIGHT_GRAY="[33[0;37m]"
local CYAN="[33[0;36m]"
local LIGHT_CYAN="[33[1;36m]"
local BLUE="[33[0;34m]"

case $TERM in
xterm*)
local TITLEBAR='[33]0;u@h:w07]'
;;
*)
local TITLEBAR=""
;;
esac

local GRAD1=$(tty|cut -d/ -f3)
PS1="$TITLEBAR
$GRAY-$CYAN-$LIGHT_CYAN(
$CYANu$GRAY@$CYANh
$LIGHT_CYAN)$CYAN-$LIGHT_CYAN(
$CYAN#$GRAY/$CYAN$GRAD1
$LIGHT_CYAN)$CYAN-$LIGHT_CYAN(
$CYAN$(date +%H%M)$GRAY/$CYAN$(date +%d-%b-%y)
$LIGHT_CYAN)$CYAN-$GRAY-
$LIGHT_GRAYn
$GRAY-$CYAN-$LIGHT_CYAN(
$CYAN$$GRAY:$CYANw
$LIGHT_CYAN)$CYAN-$GRAY-$LIGHT_GRAY "
PS2="$LIGHT_CYAN-$CYAN-$GRAY-$LIGHT_GRAY "
}

Close you Terminal and open it again.
This is what it looks like:
terminal_elite.png

Now it doesn’t yet does it?
That’s because we have to call the function:

elite

There l33t Terminal colors.
If you want the colors to stay like this without having to call the function first, add the function call to the bottom of the ~/.bashrc file.

Lets explain what where seeing in the elite function when we call it because it has some extra information.
we see:

--(madberry@Pernicious)-(3/pts)-(1728/07-Aug-08)--
--($:~)--

Explanation:

–(madberry@Pernicious): Username@Hostname
-(3/pts): Commands executed/Terminal your in(will show tty2 when you change to ctrl+alt+F2)
-(1728/07-Aug-08)–: time and date
-($:~)–: What you would normally find behind Usernae@hostname shows current path behind $.

Here is another option(which I just added to my file I like options):

function prompt
{
local WHITE="[33[1;37m]"
local GREEN="[33[0;32m]"
local CYAN="[33[0;36m]"
local GRAY="[33[0;37m]"
local BLUE="[33[0;34m]"
export PS1="
${GREEN}u${CYAN}@${BLUE}h ${CYAN}w${GRAY}$ "
}

Close and open Terminal.
This can be called with:

prompt

And this is what it looks like:
terminal_prompt.png
Same deal here if you want to keep the colors like that add prompt to the end of the ~/.bashrc file.

Now what if we want to just go back to what it was add this to the file:

function clback
{
local WHITE="[33[1;37m]"
export PS1="
${WHITE}u${WHITE}@${WHITE}h ${WHITE}w${WHITE}$ "
}

Now if you call:

clback

It changes the color back to white keep in mind that this is designed by me for the white on black color schema if your Terminal background is white then you won’t see anything.

Happy coloring 😀

Comments are closed.

Powered by: Wordpress