diff --git a/README.md b/README.md index 8840511..62a24bb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Working with Git and it's great branching/merging features is amazing. Constantl The solution to this is to have your terminal prompt display the current branch. There's a [number][1] [of][3] [articles][3] [available][4] online about how to achieve this. -I based this project mainly on [Aaron Crane's solution][1]. +I based this project mainly on Aaron Crane's [solution][1]. [1]: http://aaroncrane.co.uk/2009/03/git_branch_prompt/ [2]: http://railstips.org/2009/2/2/bedazzle-your-bash-prompt-with-git-info @@ -12,6 +12,15 @@ I based this project mainly on [Aaron Crane's solution][1]. [4]: http://www.intridea.com/2009/2/2/git-status-in-your-prompt +## Overview + +If you `cd` to a Git working directory, you will see the current Git branch name displayed in your terminal prompt like so: + +![Git Branch in Prompt](http://snap.jimeh.me/git-branch-in-prompt.png) + +When you're not in a Git working directory, your prompt works like normal. + + ## Installation Clone the project to a `.bash` folder in your home directory: @@ -24,19 +33,14 @@ Edit your `~/.bash_profile` or `~/.profile` and add the following to the top: source $DOTBASH/main.sh PS1="\u@\h:\w\[$txtcyn\]\$git_branch\[$txtrst\]\\$ " -Configure your prompt by editing the `PS1 variable`. For a list of available colors check `colors.sh`. +## Configuring -## Screenshot +If you followed the above installation instructions, you've added the default prompt style already by defining the `PS1` variable. If you don't know how to customize your prompt, I recommend you check [this][1] how-to. -![Git Branch in Prompt](http://snap.jimeh.me/git-branch-in-prompt.png) +Basically, to have the current Git branch shown, simply add `$git_branch` to your `PS1` variable, and make sure the variable value is defined with double quotes. A set of color variables have also been set for you to use. For a list of available colors check `colors.sh`. - -## Issues - -Please report any issues and bugs [here][1] on GitHub. - -[1]: http://github.com/jimeh/git-branch-in-prompt/issues +[1]: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html ## License diff --git a/colors.sh b/colors.sh index 9a023ac..bb9f995 100644 --- a/colors.sh +++ b/colors.sh @@ -1,4 +1,5 @@ -txtblk='\e[0;30m' # Black - Regular +# Regular +txtblk='\e[0;30m' # Black txtred='\e[0;31m' # Red txtgrn='\e[0;32m' # Green txtylw='\e[0;33m' # Yellow @@ -6,7 +7,9 @@ txtblu='\e[0;34m' # Blue txtpur='\e[0;35m' # Purple txtcyn='\e[0;36m' # Cyan txtwht='\e[0;37m' # White -bldblk='\e[1;30m' # Black - Bold + +# Bold +bldblk='\e[1;30m' # Black bldred='\e[1;31m' # Red bldgrn='\e[1;32m' # Green bldylw='\e[1;33m' # Yellow @@ -14,7 +17,9 @@ bldblu='\e[1;34m' # Blue bldpur='\e[1;35m' # Purple bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White -unkblk='\e[4;30m' # Black - Underline + +# Underline +unkblk='\e[4;30m' # Black undred='\e[4;31m' # Red undgrn='\e[4;32m' # Green undylw='\e[4;33m' # Yellow @@ -22,7 +27,9 @@ undblu='\e[4;34m' # Blue undpur='\e[4;35m' # Purple undcyn='\e[4;36m' # Cyan undwht='\e[4;37m' # White -bakblk='\e[40m' # Black - Background + +# Background +bakblk='\e[40m' # Black bakred='\e[41m' # Red badgrn='\e[42m' # Green bakylw='\e[43m' # Yellow