Not that this is terribly enthralling, but I figured I’d post some of the more useful parts of my .bashrc file.
Colorized prompt: starting with a newline
export PS1='\n[\e[0;32m]\u[\e[m] [\e[1;34m]\w[\e[m] [\e[1;32m]\$[\e[m] '
Putting a newline at the front of your prompt is possibly the best idea I have ever had. It creates just enough room between commands to know what’s what. Seriously, you don’t know what you’re missing.
When it comes to figuring out colors for a prompt, Arch Linux’s Color Bash Prompt wiki page is the most helpful I’ve ever seen.
Keep lots of history
I complained one day to someone that commands I use occasionally would fall out of my bash history. I’d use Ctrl+R to search for them, and when they fell out of history, I was lost.
He pointed out that it’s easy to increase the size of your history. You might as well make it huge:
I think those values are maybe a bit mismatched; see this explanation.
HISTSIZE probably doesn’t need to be 800,000 larger than allowed on-disk.
It’s a small text file. There’s really not a compelling reason to keep the file tiny. It’s possible that 200,000 lines on disk is too high, but it’s guaranteed that 1,000 is too small.
BTW, another tip: if you often rely on history search, you can add a comment on the end to aid in your search. E.g.,
git rebase -p --onto ddc4a6102051^ ddc4a6102051 # remove commit from history
If you can’t remember the command, now I can try to Ctrl+R “remove commit” or the like.
Some simple aliases
alias be='bundle exec'
alias gb='git rev-parse --abbrev-ref HEAD'
alias gpcm='git pull company master'
alias gpom='git push origin master'
gb is a handy trick to show only the current git branch name.
An alias with arguments
You can’t (to my knowledge) pass arguments to an alias. But what you can do is define a function.
For example, in the above example where I use a comment on the end to aid in searching history, because I could never remember what the thing was called?
I made it a function:
git rebase -p --onto $1^ $1
git-toss d34db33f will expand to
git rebase -p --onto d34db33f^ d34db33f, removing
d34db33f from my git history. (I will note that this is probably not a common git task.)
What else am I missing?