Created
December 27, 2013 08:07
-
-
Save JackNicholas/8143973 to your computer and use it in GitHub Desktop.
Adding name of current git branch to command line prompt
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
You can test command line prompts with commands like | |
export PS1="\W \u \$ “ | |
(then save to .bashrc or .bash_profile if want it permanently) | |
Make sure that path is up to date. | |
export PATH=/usr/local/bin:$PATH | |
The script and commands to add a coloured branch name to the prompt: Save this to .bashrc or .bash_profile | |
# Git branch in prompt. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ “ | |
Refresh terminal to make sure it works: | |
source ~/.bash_profile | |
Thanks to: | |
http://beckism.com/2009/02/better_bash_prompt/ | |
http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment