Skip to content

Instantly share code, notes, and snippets.

@replsv
Created July 16, 2014 14:27
Show Gist options
  • Save replsv/6b577f51b7ebc6e4583b to your computer and use it in GitHub Desktop.
Save replsv/6b577f51b7ebc6e4583b to your computer and use it in GitHub Desktop.
Bash profile - OSX (GIT, Python, few aliases)
alias grep='grep -i --color'
export GREP_COLOR='40;01;31'
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 /"
#| sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# Prompt
alias _userpwd='/usr/bin/perl -e '"'"'use Cwd;my $d=cwd();my $h=$ENV{"HOME"};my $dl=length($d);my $hl=length($h);if(($dl>=$hl)&&($h==substr($d,$hl))){print "~".substr($d,$hl,$dl);}else{print $d;}'"'"
export PS1="\n\[\e[32;1m\]\u \[\e[33;1m\]\w\[\e[0;1;30m\] \[\e[34;1m\]\$(parse_git_branch)\[\e[36;1m\]\[\e[36;1m\]\@\n❯ \[\e[0m\]"
export PROMPT_COMMAND='echo -ne "\033]0;$(_userpwd)\007"'
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Aliases
alias ll='ls -alF'
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment