Last active
August 29, 2015 14:27
-
-
Save lyoshenka/c7eb5a7e1b9266ed8730 to your computer and use it in GitHub Desktop.
My simple Bash prompt, before switching to liquidprompt
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
# Set prompt (including git repo info) | |
# https://gist.github.com/31631 | |
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 50 ]; then CurDir=${DIR:0:22}...${DIR:${#DIR}-25}; else CurDir=$DIR; fi' | |
if [ -f ~/Dropbox/bash/completion/git ]; then | |
source ~/Dropbox/bash/completion/git | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
PS1='\[\033[0;33m\]$(date +%H%M) \[\033[1;37m\]\h:\[\033[1;36m\]$CurDir\[\033[00m\]$(__git_ps1)\$ ' | |
elif [ -n "$(which git)" ]; then | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
PS1='\[\033[0;33m\]$(date +%H%M) \[\033[1;37m\]\h:\[\033[1;36m\]$CurDir\[\033[00m\]$(parse_git_branch)\$ ' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment