Thursday, January 27, 2011

Change prompt color (and others) on Linux terminal

Simple way:

> cd ~/
> vim .bashrc
> /force_color_prompt=yes
> delete the "#" in front of this line to uncomment it
> save (":w" in vim)

Open up a new terminal to see results!

----

The more complicated way lets you customize the prompt, you can google it.

Add date to the prompt:
key is adding the :\t: to the line, where you add ":" to separate it from other parts of the prompt. But then it would not be colored.

To add nice colors, wrap it with
:\[\033[01;33m\]\t\[\033[00m\]:

The \[\033[01;33m\] means it's the beginning of the color "33" is yellow in my case, feel free to pick another color. The \[\033[00m\] means you end this coloration.

In the end, I have this:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\t\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

No comments:

Post a Comment