Last active
March 16, 2017 09:06
-
-
Save dinusuresh/188aae63982f0a4da85623ef701a40d5 to your computer and use it in GitHub Desktop.
View git branch name and user email on terminal
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
# BEGIN -- git branch | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ >> \1 <</' | |
} | |
parse_git_email() { | |
BRANCH="$(parse_git_branch)" | |
#echo -ne "$BRANCH" | |
if [ -n "$BRANCH" ]; then | |
git config user.email | |
fi | |
} | |
# END -- git branch | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;32m\]$(parse_git_branch)\[\033[00m\] \[\033[01;37m\]$(parse_git_email)\[\033[00m\] | |
$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$(parse_git_branch)\$(parse_git_email) | |
$ ' | |
fi |
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
For Ubuntu | |
Edit ~/.bashrc file. | |
Locate the "if [ "$color_prompt" = yes ]; then else" block | |
Replace with the code in .bashrc file mentioned in this gist | |
Save file | |
Close and open terminal or perform `source ~/.bashrc` | |
Result: | |
maximus@Rome:~/sites/rome.city >> master << maximus@peekaboo.com | |
$ git checkout feature-colosseum | |
maximus@Rome:~/sites/rome.city >> feature-colosseum << maximus@peekaboo.com | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment