#!/bin/bash# The git functions are from a long-forgotten gist or blog or something.# Credit to unknown upstream author for those.# This snippet is just so I can share it.environment=`uname -s`if[["$environment"== *CYGWIN* ]]thenfunction parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"}exportPS1='\e[1;30m\][\e[\e[1;30m\]\e[1;33m\] \u@\H \[\e[1;32m\]\w\[\e[0m\] $(parse_git_branch) (check status manually) \e[1;30m\]]\e[37m\]\n> 'echo"Cygwin prompt formatting loaded - note no git status or stash parsing (too damn slow)"fiif[["$environment"== *Darwin* ]]then# mac version - git stash handled a little differentlyfunction parse_git_dirty {[[$(git status 2> /dev/null | tail -n1) !="nothing to commit, working directory clean"]]&&echo"(*)"}function parse_git_stash {[[$(git stash list 2> /dev/null | tail -n1) !=""]]&&echo"^"}function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"}# Minimal version with standard prompt and git output:# export PS1='\u@\H \w $(git branch &>/dev/null;if [ $? -eq 0 ]; then echo "$(parse_git_branch)$(parse_git_stash)"; fi) $ '# Slightly more blingyexportPS1='\e[1;37m\][\e[\e[1;37m\]\e[1;33m\] \u@\H \[\e[1;32m\]\w\[\e[0m\]$(git branch &>/dev/null;if [ $? -eq 0 ]; then echo " \[\033[01;34m\]\e[1;37m$(parse_git_branch)$(parse_git_stash)"; fi) \e[1;37m\]] \e[37m\]\n\[$PROMPT\]$ 'echo"Prompt formatting loaded"fi
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.