2021-04-22


The World's Best .bashrc?

I like to do as much work as possible directly in my bash window/terminal.

"BuT pYtHoN iS sO cOoL!"

I know, I know. But when I'm trying to do science on a computer, the less I have to jump back and forth between different terminals/windows/screens/programs/languages, the better. (And you are using Linux if you're doing serious computational science [I'm writing this in 2021], so you're probably also using bash.) And, dispite having gotten a Ph.D. by staring at a computer, I don't like to type. My mantra is "type as little as possible." So, I have been collecting cool tips and tricks that make my simple bash terminal an absolute joy to work in.

Your .bashrc is basically just a set of commands that are executed every time you start a new bash window/terminal. If there are certain commands that you'd always like to run/be in effect when you work, adding them to the .bashrc saves you from having to type them in each time you sit at your computer. By adding snippets of code into your .bashrc file, you can seriously increase the speed and efficiency with which you're able to get things done and decrease the amount you have to type, all without ever leaving the comfort of your familiar, ugly bash screen. :)

Below is a version of the .bashrc file I use in my Terminal (Mac), HPC work, and any Linux system in general. (This version is slightly simplified by removing a few software-specific lines that you wouldn't need unless you were me anyway.)

For those of you who don't like to read, I've pasted the .bashrc code right here. (I still have hints and comment lines within the code if you genuinely do already know what you're doing and just need the reminders now and then.)

For those of you that would like to know why different parts of this code are cool, I've provided explanations of different sections below. (Don't get excited; my explanations are cursory. You need to already have a vague idea about these things to make good use of this page.)