Git status in your BASH prompt
I'm a command line git user. I do 99% of my git related stuff without a GUI. I know the world is split about 50/50 between GUI users and command line users. But if you are like me, you'll love this post.
Anytime you go to do any command with git, you'll start with git status
. You have to know what branch you are one and what the local state of your repo is. I've been using bash-git-prompt
for a while to provide this info without needing to type anything. You can check out the project here: https://github.com/magicmonty/bash-git-prompt
Installing
Installation is dead simple:
cd ~
git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt --depth=1
Then add this to your ~/.bash_profile
:
GIT_PROMPT_ONLY_IN_REPO=1
source ~/.bash-git-prompt/gitprompt.sh
My customizations
I'm not a huge fan of the default settings. So I added a few customizations to my setup. I disabled remote fetching to speed up the prompt. I prefer a single line for my prompt. I use stashes for work in progress code so I don't want my stash count included in the prompt.
Customizations added in ~/.bash_profile
GIT_PROMPT_FETCH_REMOTE_STATUS=0 #avoid fetching remote status
GIT_PROMPT_THEME=Single_line_Ubuntu #better theme
GIT_PROMPT_IGNORE_STASH=1 #ignore any stashes.
This leaves my prompt looking like: