public
Created

My Bash Profile

  • Download Gist
.bash_profile
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
 
export USER="tomas-stefano"
 
# Colours
export BLUE="\[\033[0;34m\]"
export NO_COLOR="\[\e[0m\]"
export GRAY="\[\033[1;30m\]"
export GREEN="\[\033[0;32m\]"
export LIGHT_GRAY="\[\033[0;37m\]"
export LIGHT_GREEN="\[\033[1;32m\]"
export LIGHT_RED="\[\033[1;31m\]"
export RED="\[\033[0;31m\]"
export WHITE="\[\033[1;37m\]"
export YELLOW="\[\033[0;33m\]"
 
# ls and grep colorize
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="4;33"
export CLICOLOR="auto"
export GEM_EDITOR="mate"
 
alias ls='ls -G'
 
alias textmate_rails="mate app config db features lib public spec Tasks"
 
alias cd_gems="cd ~/Codigos/Ruby/gems/"
 
alias cd_libs="cd ~/Codigos/C/"
 
alias mysqlraw="mysql -u tdestefi -p -h 69.46.19.48 raw"
alias server_infoplex="ssh -v tdestefi@69.46.19.62"
 
alias jsonget="curl -X GET -H 'Accept: application/json'"
 
alias databases_mate="mate ~/Codigos/C/mongo ~/Codigos/C/couchdb ~/Codigos/C/DruidDB ~/Codigos/C/redis-2.0.3"
 
alias start_redis="redis-server /usr/local/etc/redis.conf"
 
alias read_ruby_source_code="mate ~/.rvm/src/ruby-1.9.2-p0/"
 
alias gem_uninstall_all="gem list | cut -d\" \" -f1 | fgrep -v bundler | fgrep -v rake | fgrep -v rdoc | xargs gem uninstall -aIx"
 
 
# Projetos
alias infoplex_prepare='cd ~/Projetos/Infoplex && clear'
alias rubycasts="cd ~/Projetos/rubycasts && ls"
alias reblog="cd ~/Projetos/reblog && ls"
 
# Set window title
title() {
echo -ne "\033]0;$@\007";
}
 
# list directory after cd; also save the last directory
# and open it when a new tab is created.
cd() {
builtin cd "${@:-$HOME}" && ls && pwd > $CDHISTORY;
 
if [ -f .rvmrc ]; then
__rvm_project_rvmrc
fi
}
 
github() {
if [ $# = 1 ]; then
git clone git@github.com:$USER/$1.git;
builtin cd $1 && ls;
elif [ $# = 2 ]; then
git clone git://github.com/$1/$2.git;
builtin cd $2 && ls;
else
echo "Usage:";
echo " github <repo> ~> will clone $USER's <repo>";
echo " github <user> <repo> ~> will clone <user>'s <repo>";
fi
}
 
custom_prompt () {
local BRANCH=`git branch 2> /dev/null | grep \* | sed 's/* //'`
 
if [[ "$BRANCH" = "" ]]; then
BRANCH=`git status 2> /dev/null | grep "On branch" | sed 's/# On branch //'`
fi
 
local RUBY_VERSION=`ruby -e "puts RUBY_VERSION"`
local GEMSET_NAME=`rvm gemset name`
local RUBY_PROMPT=""
local STATUS=`git status 2>/dev/null`
local PROMPT_COLOR=$GREEN
local STATE=" "
local NOTHING_TO_COMMIT="# Initial commit"
local BEHIND="# Your branch is behind"
local AHEAD="# Your branch is ahead"
local UNTRACKED="# Untracked files"
local DIVERGED="have diverged"
local CHANGED="# Changed but not updated"
local TO_BE_COMMITED="# Changes to be committed"
local LOG=`git log -1 2> /dev/null`
 
if [[ "$GEMSET_NAME" != "" ]]; then
RUBY_PROMPT="${RED}(ruby-${RUBY_VERSION}@${GEMSET_NAME})${NO_COLOR} "
else
RUBY_PROMPT="${RED}(ruby-${RUBY_VERSION})${NO_COLOR} "
fi
 
if [ "$STATUS" != "" ]; then
if [[ "$STATUS" =~ "$NOTHING_TO_COMMIT" ]]; then
PROMPT_COLOR=$RED
STATE=""
elif [[ "$STATUS" =~ "$DIVERGED" ]]; then
PROMPT_COLOR=$RED
STATE="${STATE}${RED}↕${NO_COLOR}"
elif [[ "$STATUS" =~ "$BEHIND" ]]; then
PROMPT_COLOR=$RED
STATE="${STATE}${RED}↓${NO_COLOR}"
elif [[ "$STATUS" =~ "$AHEAD" ]]; then
PROMPT_COLOR=$RED
STATE="${STATE}${RED}↑${NO_COLOR}"
elif [[ "$STATUS" =~ "$CHANGED" ]]; then
PROMPT_COLOR=$RED
STATE=""
elif [[ "$STATUS" =~ "$TO_BE_COMMITED" ]]; then
PROMPT_COLOR=$RED
STATE=""
else
PROMPT_COLOR=$GREEN
STATE=""
fi
 
if [[ "$STATUS" =~ "$UNTRACKED" ]]; then
STATE="${STATE}${YELLOW}*${NO_COLOR}"
fi
 
PS1=" ${RUBY_PROMPT}${YELLOW}\w\a${NO_COLOR} (${PROMPT_COLOR}${BRANCH}${NO_COLOR}${STATE}${NO_COLOR})\n⤷ "
else
PS1=" ${RUBY_PROMPT}${YELLOW}\w\a${NO_COLOR}\n⤷ "
fi
}
source ~/.git_completion.sh
 
#PS1='\n[\u] \[\033[1;33m\]\w\a\[\033[0m\]$(__git_ps1 "
# \[\033[1;32m\](%s)\[\033[0m\]")\n\$ '
 
#export PS1='\[\033[38m\]\u\[\033[32m\] \w \[\033[1;33m\]`~/.rvm/bin/rvm-prompt i v
#`\[\033[0;31m\] `git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\
#\(.+\)$/\(\\\\\1\)\ /
#`\[\033[37m\]$\[\033[00m\] '
 
PROMPT_COMMAND=custom_prompt
 
# export PS1="\033[32m\]\w \[\033[1;33m\]\$(rvm_version)\[\033[0;31m\]\$(parse_git_branch)
# \033[0m "
 
#PS1='\n[\u] \[\033[1;34m\]\w\a\[\033[0m\]$(__git_ps1 "
# \[\033[1;32m\](%s)\[\033[0m\]")\n\$ '
 
# rvm-install added:
if [[ -s /Users/tomas/.rvm/scripts/rvm ]] ; then source /Users/tomas/.rvm/scripts/rvm ; fi
 
source ~/.profile

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.