Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Created March 27, 2013 19:55
Show Gist options
  • Save erickgnavar/5257488 to your computer and use it in GitHub Desktop.
Save erickgnavar/5257488 to your computer and use it in GitHub Desktop.
Bash template
# common
alias grep="grep --color=auto"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
function find_word() {
if [ $1 ]; then
find . -type f -name "*.py" -exec grep --color=always -nH "$1" {} \;
else
echo "Enter a word";
fi
}
alias venv="source ../venv/bin/activate";
os=`uname`
if [ $os == "Darwin" ]; then
#link selenium
alias selenium-server="java -jar /usr/local/Cellar/selenium-server-standalone/2.25.0/selenium-server-standalone-2.25.0.jar"
alias jenkins="java -jar /usr/local/opt/jenkins/libexec/jenkins.war"
#Python-Mysql
function fix_mysql_python() {
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
}
export PATH=/usr/local/Cellar/gettext/0.18.2/bin:$PATH
#fix git in mac to select updated git version
export PATH=/usr/local/bin:/usr/local/mysql/bin:$PATH:/usr/local/sbin
#opencv
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
#Mongo in macbook
alias mongod="mongod --dbpath /data/db/"
# Composer
alias composer="php /usr/local/bin/composer.phar"
# Glassfish admin
alias asadmin="/usr/local/Cellar/glassfish/3.1.2/bin/asadmin";
#Sublime shortcut
function sublime() {
if [ $1 ]; then
open $1 -a "sublime text 2";
else
echo "Enter a valid input";
fi
}
#Sourcetree
function sourcetree() {
if [ $1 ]; then
open $1 -a "SourceTree";
else
echo "Enter a valid input";
fi
}
#Alias
alias hideDesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder";
alias showDesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder";
alias showHiddenFiles="defaults write com.apple.Finder AppleShowAllFiles YES && killall Finder";
alias hideHiddenFiles="defaults write com.apple.Finder AppleShowAllFiles NO && killall Finder";
fi
#Fix django problem
export LANG="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_ALL=
#Set color to terminal
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
function source() {
command source "$@";
update_prompt
}
function git () {
command git "$@"
if [ $1 == "checkout" ]; then
update_prompt
fi
}
function cd () {
command cd "$@"
update_prompt
}
export BRANCH=""
function print_branch() {
branch=`git branch 2>/dev/null | grep '*' | awk '{print $2}'`
c=`echo "${#branch}"`
if [ $c != 0 ]; then
export BRANCH=" [git:$branch]";
else
export BRANCH=""
fi
}
function update_prompt () {
print_branch
export PS1="$(virtualenv_info)$USER$AT$HOST $MAGENTA$(get_pwd)$WHITE$BRANCH $DOLLAR\n$WHITE → $RESET"
}
function virtualenv_info () {
[ $VIRTUAL_ENV ] && echo "("`basename $VIRTUAL_ENV`") ";
}
function get_pwd() {
echo "${PWD/$HOME/~}"
}
#COLORS
RESET="\[\033[0m\]"
BLACK="\[\033[30m\]"
RED="\[\033[31m\]"
GREEN="\[\033[32m\]"
YELLOW="\[\033[33m\]"
BLUE="\[\033[34m\]"
MAGENTA="\[\033[35m\]"
CYAN="\[\033[36m\]"
WHITE="\[\033[37m\]"
#set color to prompt
USER="$RED\u"
HOST="$YELLOW\h"
DOLLAR="$CYAN\$ $RESET"
AT="$WHITE at "
update_prompt
# {{{
# Node Completion - Auto-generated, do not touch.
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
# }}}
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment