colored prompt

export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
It colors the machine name and current directory different colors for easy viewing.

By: kamiller
2009-03-18 22:05:48

What Others Think

Sweet hack! Thanks. How can I change the colors?
sudopeople · 653 weeks and 3 days ago
Christmas colors: export PS1='\[\033[0;32m\]\h\[\033[0;31m\] \w\[\033[00m\]: ' Helpful:
sudopeople · 653 weeks and 2 days ago
reset: export PS1='\h \w: ' (for when you screw up :)
sudopeople · 653 weeks and 2 days ago
if you want a color depending on the mac address: UNIQUE_BY_MAC=$(ifconfig |grep eth0|awk '{ print strtonum("0x"substr($6,16,2)) }') R=3$((UNIQUE_BY_MAC%6 + 1)); PS1="\n\[\033[1;37m\]\u@\[\033[1;$R""m\]\h^$UNIQUE_BY_MAC:\[\033[1;37m\]\w\$\[\033[0m\] "
rubo77 · 516 weeks and 3 days ago
added in my labnotes... thanks!
0disse0 · 516 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: