Created
February 22, 2009 00:53
-
-
Save andyferra/68269 to your computer and use it in GitHub Desktop.
prompt with git branch and working directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ~/git-ps1.rb | |
green = "\033[0;32m" | |
red = "\033[0;31m" | |
base = "\033[0;37m" # <-- Needs to be set to whatever your shell base colors is | |
current_branch = `git branch 2>/dev/null`.grep(/^\*/).first | |
if current_branch | |
branch_name = current_branch.gsub(/^\*\s*/,'').strip | |
color = branch_name =~ /master/ ? green : red | |
puts "#{color}[#{branch_name}]#{base}" unless current_branch.empty? | |
end | |
## ~/.ps | |
parse_git_branch() { | |
ruby ~/git-ps1.rb | |
} | |
export PS1="\n\w \$(parse_git_branch)\n$ " | |
## add this to ~/.bash_profile, ~/.bashrc, etc. | |
. ~/.ps | |
# git branch via http://www.furmanek.net/39/unix-prompt-for-usage-with-git/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment