Topic: Need help theming bash colors and the like

Hey guys,

as the title implies ive been trying to understand the proper way to colorize my bash and vim. I have seen really amazing screenshots over the years of people using tiling window managers who all seem to have really awesome text colors, and as I have been simplifying my experience as much as possible I would like to adopt this for my desktop. My research has led me to believe that this is done (in some cases) by editing the .xsession or .xdefaults files but my attempts to locate either of these (using debian lenny) has been diffucult.

can anyone explain to me the best way of going about doing this or at the very least direct me to a current guide so that I may figure it out on my own.

very grateful,
mamba

to recap i intend to colorize bash and vim mostly

Last edited by blackmamba (2010-11-23 21:00:24)

Re: Need help theming bash colors and the like

Hi, blackmamba :-)

I'm a bit new to customizing bash, too, but what I've figured out so far is this: you need a terminal that supports colour, so try installing urxvt (rxvt-unicode in the repos). Then create an .Xdefaults file in your home folder (this may not already exist) and paste in the contents of an example you like from one of the various threads on #! forums (this one, for example). You can customise it from there.

Vim syntax colouring can be achieved with the Color Sampler Pack plugin (and the ScrollColors plugin for easier navigation). Instructions for installing those plugins are on the plugin pages.

The tiling window manager is something I'd like to use, too, but haven't got that far yet :-)

"Stranger, if you passing meet me and desire to speak to me, why should you not speak to me? And why should I not speak to you?" Walt Whitman, 'To You'.

Re: Need help theming bash colors and the like

Thanks alot for the reply safetycopy this is a good start. At least i now know that you can create the .xdefaults file if need be lol. This will definetely get me going but if anyone else knows of some good documenatation for editing these files, ie which elements of bash you are able to colorize, that would be great. Ill be picking apart the examples listed in safetycopys link but id like a masterlist if there is such a thing.

Cheers

Re: Need help theming bash colors and the like

hey mamba, as far as theming your "PS1" which is the bash prompt, you'll need to do a "man bash" and check out the manual.  Colors are set for prompts via escape codes.  for example \[\033[34m\] is blue I believe.  Here is a good article on it.  http://www.linuxselfhelp.com/howtos/Bas … WTO-6.html

You put your ps1 stuff in .bashrc  You can also put it in .profile  It's recommended to use .bashrc though for best practice, because .profile sources vairous stuff other than bash.

Well, you gotta live no matter what happens.  -Dallas (John Ford's Stagecoach 1939 Public Domain)

Re: Need help theming bash colors and the like

thnx for the tip rstrcogburn ill look intp that. i remember hearing that the colors for PS1 were ANSI based so i never took to deep of a look at it.

Re: Need help theming bash colors and the like

Have a bit of time waiting for clients to arrive... guess I'll spam for kicks!!

@Mamba
I think safetycopy's Vim related links should give you a good start in that area.

Now, with regards to bash and it's PS1 prompt..etc;
I assume you're on Debian or #! Statler using it's default Bash shell (as opposed to ZSH or KSH), so I grabbed the .bashrc included in Statler and modified it, to make it a touch easier for you to grasp, and also because I suck at explaining stuff from scratch and prefer using examples instead >_<

Around a year ago, I decided my cranium had better stuff to remember than those weird rhythm-challenged term ANSI numbers, so I did some reading around the Debian, Gentoo, Ubuntu and Arch forums, added a bit of of my own nonsense, and ended up with this;

# ANSI color codes
RS="\[\033[0m\]"    # reset
HC="\[\033[1m\]"    # hicolor
UL="\[\033[4m\]"    # underline
INV="\[\033[7m\]"   # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLE="\[\033[34m\]" # foreground blue
FMAG="\[\033[35m\]" # foreground magenta
FCYN="\[\033[36m\]" # foreground cyan
FWHT="\[\033[37m\]" # foreground white
BBLK="\[\033[40m\]" # background black
BRED="\[\033[41m\]" # background red
BGRN="\[\033[42m\]" # background green
BYEL="\[\033[43m\]" # background yellow
BBLE="\[\033[44m\]" # background blue
BMAG="\[\033[45m\]" # background magenta
BCYN="\[\033[46m\]" # background cyan
BWHT="\[\033[47m\]" # background white

Basically, we're sort of aliasing the escape codes (or whatever they're called).

You insert that bit into your .bashrc, before any PS1 related lines.
Then you proceed to edit your PS1 accordingly, adding a $ before each color alias, which in turn should be applied before each attribute you want in the prompt .... or something like that....
Here's the standard Statler .bashrc I grabbed and added the related customizations to... it'll probably give you a better idea.
http://pastebin.com/epceAWiB
The color bits are on lines 52 - 72, and the modded PS1 and PS2 prompts are  lines 84 & 85. Hope this gives you a simple enough example/start point.

I also copy-pasted some bits that give you colored man pages, lines 117 - 124, from somewhere on these forums

If you want to know what the prompt looks like, here's a recent screenshot, prompt in the center of the screen. My preferred terminal emulator is Urxvt (rxvt-unicode), btw.
http://ompldr.org/tNjBxcQ

For an example .Xdefaults colorscheme, refer to Tartan's awesome (yet under-visited) thread over at the Tips & Tricks section:
http://crunchbanglinux.org/forums/topic … creenshot/ (edit: Oops, safetycopy already pointed this one out, it seems)


Edit:
Some additional reference that might interest you;
Reading the article rstcogburn linked to is advisable before you click these,
https://wiki.archlinux.org/index.php/Xdefaults
http://www.gilesorr.com/bashprompt/prompts/
http://bashish.sourceforge.net/

INB4-U-MOVE-2-ZSH tongue


Edit2:
You probably know this already, but just in case you didn't....
...all those screenshots you've seen of tilers with lots of colours, it actually involves a bit more than simple .Xdefaults and .bashrc/.zshrc editing. You also need to edit the individual config files of term apps in most cases (just like you would with Vim or Emacs). Apps like Ncmcpp, MoC, Midnight Commander, Newsbeuter, Mutt, irssi..etc all have their respective config or theme files that you can play around with.


Cheers~!!

Last edited by gutterslob (2010-11-24 10:41:10)

Point & Squirt

Re: Need help theming bash colors and the like

wow thnx for going the extra mile on that post gutterslob, this is exactly what i was looking for. once i get some time to play around with this ill post of the result.

thnx again m8

cheers