Instantly share code, notes, and snippets.

Embed
What would you like to do?
.bash_profile
# setup terminal locales
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
# list all colors avaiable on your terminal
function list_colors {
clear
T='colors'
echo -e "\n\t 40m 41m 42m 43m 44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
}
NONE="\[\033[0m\]" # unsets color to term's fg color
# regular colors
K="\[\033[0;30m\]" # black
R="\[\033[0;31m\]" # red
G="\[\033[0;32m\]" # green
Y="\[\033[0;33m\]" # yellow
B="\[\033[0;34m\]" # blue
M="\[\033[0;35m\]" # magenta
C="\[\033[0;36m\]" # cyan
W="\[\033[0;37m\]" # white
# emphasized (bolded) colors
EMK="\[\033[1;30m\]"
EMR="\[\033[1;31m\]"
EMG="\[\033[1;32m\]"
EMY="\[\033[1;33m\]"
EMB="\[\033[1;34m\]"
EMM="\[\033[1;35m\]"
EMC="\[\033[1;36m\]"
EMW="\[\033[1;37m\]"
# background colors
BGK="\[\033[40m\]"
BGR="\[\033[41m\]"
BGG="\[\033[42m\]"
BGY="\[\033[43m\]"
BGB="\[\033[44m\]"
BGM="\[\033[45m\]"
BGC="\[\033[46m\]"
BGW="\[\033[47m\]"
# checks if current git branch is modified
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
# returns branch name and a * if it's modified
function git_status {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty)) /"
}
# flush dns shortcut
function flushdns {
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
}
# Exports
export GREP_OPTIONS='--color=auto' # set color output for grep
export HISTCONTROL="erasedups:ignoredups" # ignore duplicated commands on bash history
export HISTSIZE=10000 # set history size to 10k
export CLICOLOR=1 # turn on colors
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx # setup colors
export PS1="${Y}λ${NONE} ${W}\W${NONE} ${M}\$(git_status)${B}>${NONE} " # setup prompt
export PATH="$PATH:$HOME/.rvm/bin" # setup rvm
# Aliases
alias ls="ls -G" # setup ls to always output colors
alias please="sudo" # syntax sugar
alias pow="powify" # powify is called with pow command
# Init history
shopt -s histappend
# setup bash_completion
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
source "$rvm_path/scripts/rvm"
source ".rvmrc"
fi
# added by travis gem
[ -f /Users/jmorais/.travis/travis.sh ] && source /Users/jmorais/.travis/travis.sh
clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment