I read a great post on HN written by Lei Mao talking about the differences between the various "profile" scripts - .bashrc, .profile, .bash_profile - and it made me realize just how long it's been since I looked at my personal Bash profile. I figure the beginning of the year is as good a time as any to take a walk through my personal .bashrc file and see if I can even remember what everything does ;) If you'd like a copy to follow along or for your own personal use, here you go:
I want to start with a couple of caveats - first, I'm sure my profile isn't nearly as interesting or cutting-edge as some others. Yes, it's kind of simple, but I've been using it for almost 7 years now and it's performed solidly. Second, in order to use it on your box you will need to install a couple of applications (we'll go over those below). Finally, I'm a Debian guy and so is my profile; it should work on the most recent Debian-based distros including Ubuntu, but YMMV (if I can find my old Gentoo .bashrc I'll write it up in a separate article).
Ok, so let's jump right in!
First off, a couple of comments and then we set the prompts - green and blue and "$" for regular users, red and blue and "#" for root. As you can see from the
debian_chroot reference, this section is a leftover from the original Debian file:
Next, I like my terminals to have a lot of color. By aliasing some commands and using
dircolors and the application grc I can add color to some of the commands I use most frequently:
Next up, due to my tendency to work long hours and general brain fuzziness, I set up some bumper rails for myself:
Finally, I added two other function aliases that I found myself using frequently - rsync-over-SSH and using the
pandoc command to read Markdown files in the terminal:
If you're wanting to recreate my .bashrc on your system, you will need to install the applications grc, rsync, and pandoc (I'm assuming SSH is already installed):
apt-get install grc rsync pandoc
It's not flashy and it may not win any awards, but it's one of the fundamental tools in my toolkit. Anytime I'm building a new server, after setting up my .ssh directory and
authorized_keys file, I install the helper apps and copy over my .bashrc. If nothing else, feel free to use my example to build a bigger and better profile to suit your daily admin needs.