Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created December 12, 2012 21:33
Show Gist options
  • Save alex-zige/4271821 to your computer and use it in GitHub Desktop.
Save alex-zige/4271821 to your computer and use it in GitHub Desktop.
better looking bash_profile + integrated with git
GitHub:Gist GitHub:Gist
public
mdigital / gist:2907430
.bash_profile including set_title and git prompt
Gist Detail
Revisions 1
Clone this gist
Embed this gist
gistfile1.txt 781 Bytes
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1$(parse_git_dirty)]/"
}
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
PS1='\n\e[32m\][\A][\[\e[1;32m\]\h\[\e[0;32m\]][\[\e[1;32m\]\w\[\e[0;32m\]]\e[0m\]\e[01;31m\]$(parse_git_branch)\e[0m\]\n\n> '
function st { title=$1; echo -e "\033];${title}\007"; }
unset color_prompt force_color_prompt
Please sign in to comment on this gist.
© 2012 GitHub Inc. All rights reserved.
The GitHub Blog
Support
Contact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment