Thursday, September 10, 2020

Making a comfortable dev environment

Coding? Debugging? Configuring? These are a few simple things that have been very helpful to me and  my colleagues.

1. Bash prompt++. 

It helps to put your machine's name, dir, and branch name into the bash prompt to save you from 1) running whoami or ipconfig a thousand times 2) running pwd a thousand times 3) running git status every other minute. Here is mine:

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1="\[\e[34m\]\h\[\e[m\]:\[\e[33m\]\w\[\e[00m\]\$(parse_git_branch)$ "

It should look something like this:

myMacYeah:~/dev/betteromics/ (df/fix_commit)$

where myMacYeah is my machine, followed by directory, and then the branch name I am currently on

2. Aliases

Create aliases, please! For so many years, I deprived myself of this pleasure to speak in a more consise command language that only me and my machine would understand... No more! ls -ls becomes an easy ll, git branch -v becomes a friendly gbra (or should I have gone w/ g-bro? 😆), gsta substitutes git status. Boldly go into the unknown!

3. Git commands autocomplete

This is just plain poetry for thy tired eyes (and fingers) when you don't need to fully type out all the delicate git commands, one letter after another. Download, add a couple of lines to your bash_profile, and live in a fast lane. Thank you so much, Shawn O'Pearce!

# add git commands autocomplete
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi