export PATH="$HOME/.rbenv/bin:$PATH" export ZSH=$HOME/.oh-my-zsh source ~/.git-prompt.sh export GIT_PS1_SHOWDIRTYSTATE=1 # Configuring Our Prompt # ====================== # This function is called in your prompt to output your active git branch. # function parse_git_dirty { # [[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working directory clean" ]] && echo "✔" # [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo # # if [[ ! ${git_status}} =~ "nothing to commit, working directory clean" ]]; then state="✘" # # fi [[ ${git_status}} =~ "nothing to commit, working directory clean" ]]; then state="✔" # } # add this for dirty branch $(__git_ps1 "(%s $(parse_git_dirty))") function parse_git_dirty { [[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working directory clean" ]] && echo " ✔" [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo " ✘" } # function parse_git_branch { # git branch --blue 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" # } function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/" } # This function builds your prompt. It is called below function prompt { # Define some local colors local RED="\[\033[0;31m\]" # This syntax is some weird bash color thing I never local LIGHT_RED="\[\033[1;31m\]" # really understood local CHAR="⛵" local BLUE="/e[0;34m" # local white="\e[1;37m" # ♥ ☆- Keeping some cool ASCII Characters for reference # Here is where we actually export the PS1 Variable which stores the text for your prompt export PS1="wd: \[\e[32m\]\W\[\e[0m\]\[\e[0;31m\]\[$IRED\] (ruby v: \$(rvm_version))\$(parse_git_branch)$\n⛵ \[\e[0m\]" # ^put \n to have it on the next line # add this for time stamp "\[\e]2;\u@\h\a[\[\e[37;44;1m\]\t\[\e[0m\]]$white" PS2='> ' PS4='+ ' } # Finally call the function and our prompt is all pretty prompt # For more prompt coolness, check out Halloween Bash: # http://xta.github.io/HalloweenBash/ # If you break your prompt, just delete the last thing you did. # And that's why it's good to keep your dotfiles in git too. # Environment Variables # ===================== # Library Paths # These variables tell your shell where they can find certain # required libraries so other programs can reliably call the variable name # instead of a hardcoded path. # NODE_PATH # Node Path from Homebrew I believe export NODE_PATH="/usr/local/lib/node_modules:$NODE_PATH" # PYTHON_SHARE # Python Shared Path from Homebrew I believe # export PYTHON_SHARE='/usr/local/share/python' # Those NODE & Python Paths won't break anything even if you # don't have NODE or Python installed. Eventually you will and # then you don't have to update your bash_profile # Configurations # GIT_MERGE_AUTO_EDIT # This variable configures git to not require a message when you merge. export GIT_MERGE_AUTOEDIT='no' # Editors # Tells your shell that when a program requires various editors, use sublime. # The -w flag tells your shell to wait until sublime exits export VISUAL="subl -w" export SVN_EDITOR="subl -w" export GIT_EDITOR="subl -w" export EDITOR="subl -w" # Paths # The USR_PATHS variable will just store all relevant /usr paths for easier usage # Each path is seperate via a : and we always use absolute paths. # A bit about the /usr directory # The /usr directory is a convention from linux that creates a common place to put # files and executables that the entire system needs access too. It tries to be user # independent, so whichever user is logged in should have permissions to the /usr directory. # We call that /usr/local. Within /usr/local, there is a bin directory for actually # storing the binaries (programs) that our system would want. # Also, Homebrew adopts this convetion so things installed via Homebrew # get symlinked into /usr/local export USR_PATHS="/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin" # Hint: You can interpolate a variable into a string by using the $VARIABLE notation as below. # We build our final PATH by combining the variables defined above # along with any previous values in the PATH variable. # Our PATH variable is special and very important. Whenever we type a command into our shell, # it will try to find that command within a directory that is defined in our PATH. # Read http://blog.seldomatt.com/blog/2012/10/08/bash-and-the-one-true-path/ for more on that. export PATH="$USR_PATHS:$PYTHON_SHARE:$PATH" # If you go into your shell and type: $PATH you will see the output of your current path. # For example, mine is: # /Users/avi/.rvm/gems/ruby-1.9.3-p392/bin:/Users/avi/.rvm/gems/ruby-1.9.3-p392@global/bin:/Users/avi/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/avi/.rvm/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/mysql/bin:/usr/local/share/python:/bin:/usr/sbin:/sbin: # Helpful Functions # ===================== # A function to CD into the desktop from anywhere # so you just type desktop. # HINT: It uses the built in USER variable to know your OS X username # USE: desktop # desktop subfolder function desktop { cd /Users/$USER/Desktop/$@ } # A function to easily grep for a matching file # USE: lg filename function lg { FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'` REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'` ls -la | grep "[$FIRST]$REST" } # A function to easily grep for a matching process # USE: psg postgres function psg { FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'` REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'` ps aux | grep "[$FIRST]$REST" } # A function to extract correctly any archive based on extension # USE: extract imazip.zip # extract imatar.tar function extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) rar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi } # From http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/ # I had to change 'git-symbolic-ref' to 'git symbolic-ref' # function parse_git_branch { # ref=$(git symbolic-ref HEAD 2> /dev/null) || return # echo " ["${ref#refs/heads/}"]" # I wanted my branch wrapped in [], use () or <> or whatever # } # PS1="\w \$(parse_git_branch)\$ " UNCOMMENT^^^^ AND AND ADD <===== TO PROMPT LINE TO WORK # from http://ariejan.net/2010/04/25/ruby-version-and-gemset-in-your-bash-prompt-yes-sir function rvm_version { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') [ "$version" != "" ] && version="$version" local full="$version$gemset" [ "$full" != "" ] && echo "${full}" # the colon at the end is a delimiter, you could use a space instead } # ADD THIS TO PS1 = "\[$IRED\]\$(rvm_version)\[$NO_COLOR\]\W\[$IGRN\][$NO_COLOR\] \$" # Aliases # ===================== # LS alias l='ls -lah' # Git alias gst="git status" alias gl="git pull" alias gp="git push" alias gd="git diff | mate" alias gc="git commit -v" alias gca="git commit -v -a" alias gb="git branch" alias gba="git branch -a" # Final Configurations and Plugins # ===================== # Git Bash Completion # Will activate bash git completion if installed # via homebrew if [ -f `brew --prefix`/etc/bash_completion ]; then . `brew --prefix`/etc/bash_completion fi # RVM # Mandatory loading of RVM into the shell # This must be the last line of your bash_profile always # [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* [[ -s "/Users/$USER/.rvm/scripts/rvm" ]] && source "/Users/$USER/.rvm/scripts/rvm"