Created
February 23, 2015 20:29
-
-
Save marianboda/7f92be3ba73fab08dcda to your computer and use it in GitHub Desktop.
OS X .bash_profile
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
if [ -x /usr/bin/tput ] && tput setaf 1 >& /dev/null; then | |
c_git_clean=$(tput setaf 2) | |
c_git_dirty=$(tput setaf 1) | |
c_git_semi_dirty=$(tput setaf 3) | |
c_reset=$(tput sgr0) | |
else | |
c_git_clean= | |
c_git_dirty= | |
c_reset= | |
c_git_semi_dirty= | |
fi | |
git_prompt () | |
{ | |
if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
return 0 | |
fi | |
git_branch=$(git branch 2> /dev/null | sed -n '/^\*/s/^\* //p') | |
if git diff HEAD --quiet 2> /dev/null >&2; then | |
git_color="${c_git_clean}" | |
dirty=0 | |
else | |
git_color="${c_git_dirty}" | |
dirty=1 | |
fi | |
if git diff $git_branch origin/$git_branch --quiet 2> /dev/null >&2; then | |
git_color="$git_color" | |
else | |
if [ dirty=0 ]; then | |
git_color="${c_git_semi_dirty}" | |
fi | |
fi | |
echo " $git_color[$git_branch]${c_reset}" | |
} | |
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$(git_prompt) \$ " | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad | |
alias ls='ls -GFh' | |
alias tree='tree -CF' | |
# Append to the Bash history file, rather than overwriting it | |
shopt -s histappend; | |
# Autocorrect typos in path names when using `cd` | |
shopt -s cdspell; | |
# Enable some Bash 4 features when possible: | |
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` | |
# * Recursive globbing, e.g. `echo **/*.txt` | |
for option in autocd globstar; do | |
shopt -s "$option" 2> /dev/null; | |
done; | |
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring | |
# the `.git` directory, listing directories first. The output gets piped into | |
# `less` with options to preserve color and line numbers, unless the output is | |
# small enough for one screen. | |
function tre() { | |
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment