Skip to content

Instantly share code, notes, and snippets.

@alexcusack
Created October 16, 2018 03:21
Show Gist options
  • Select an option

  • Save alexcusack/24f89cb641c9196ce538edd66ee73fb1 to your computer and use it in GitHub Desktop.

Select an option

Save alexcusack/24f89cb641c9196ce538edd66ee73fb1 to your computer and use it in GitHub Desktop.

Revisions

  1. alexcusack created this gist Oct 16, 2018.
    126 changes: 126 additions & 0 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,126 @@
    # echo is like puts for bash (bash is the program running in your terminal)
    echo "Loading ~/.bash_profile"

    # $VARIABLE will render before the rest of the command is executed
    echo "Logged in as $USER at $(hostname)"

    # Load RVM into a shell session *as a function*
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
    # Path for RVM
    test -d "$HOME/.rvm/bin" && PATH="$PATH:$HOME/.rvm/bin"

    # Rbenv autocomplete and shims
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
    # Path for RBENV
    test -d "$HOME/.rbenv/" && PATH="$HOME/.rbenv/bin:$PATH"

    # Path changes are made non-destructive with PATH=new_path;$PATH This is like A=A+B so we preserve the old path

    # Path order matters, putting /usr/local/bin before /usr/bin
    # ensures brew programs will be seen and used before another program
    # of the same name is called

    # Path for brew
    test -d /usr/local/bin && export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
    # Path for Heroku
    test -d /usr/local/heroku/ && export PATH="/usr/local/heroku/bin:$PATH"

    # Load git completions
    git_completion_script=/usr/local/etc/bash_completion.d/git-completion.bash
    test -s $git_completion_script && source $git_completion_script

    # A more colorful prompt
    RED='\[\e[0;31m\]'
    GREEN='\[\e[0;32m\]'
    BLUE="\[\033[1;34m\]"
    COLOR_NONE="\[\e[0m\]"
    # \[\e[0m\] resets the color to default color
    c_reset='\[\e[0m\]'
    # \e[0;31m\ sets the color to red
    c_path=${RED}
    # \e[0;32m\ sets the color to green
    c_git_clean=${GREEN}
    # \e[0;31m\ sets the color to red
    c_git_dirty=${RED}

    # determines if the git branch you are on is clean or dirty
    git_prompt ()
    {
    # Is this a git directory?
    if ! git rev-parse --git-dir > /dev/null 2>&1; then
    return 0
    fi
    # Grab working branch name
    git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
    # Clean or dirty branch
    if git diff --quiet 2>/dev/null >&2; then
    git_color="${c_git_clean}"
    else
    git_color=${c_git_dirty}
    fi
    echo " [$git_color$git_branch${c_reset}]"
    }

    function set_virtualenv () {
    if test -z "$VIRTUAL_ENV" ; then
    PYTHON_VIRTUALENV=""
    else
    PYTHON_VIRTUALENV="${BLUE}[`basename \"$VIRTUAL_ENV\"`]${COLOR_NONE}"
    fi
    }

    function set_prompt() {
    set_virtualenv
    PS1="${PYTHON_VIRTUALENV}${c_path}\W${c_reset}$(git_prompt) :> "
    }

    PROMPT_COMMAND=set_prompt


    export VIRTUALENV_PYTHON=/usr/local/bin/python

    # Colors ls should use for folders, files, symlinks etc, see `man ls` and
    # search for LSCOLORS
    export LSCOLORS=ExGxFxdxCxDxDxaccxaeex
    # Force ls to use colors (G) and use humanized file sizes (h)
    alias ls='ls -Gh'

    # Force grep to always use the color option and show line numbers
    export GREP_OPTIONS='--color=always'

    # Set sublime as the default editor
    which -s subl && export EDITOR="subl --wait"

    pl() {
    if [ -z "$1" ]
    then
    echo "specify a ticket number"
    else
    open https://meetearnest.atlassian.net/browse/plsvc-$1
    fi
    }

    # Useful aliases
    alias e="subl"

    function notes {
    history | grep '#'
    }

    function previous {
    history | grep $1
    }

    function usepython {
    source /usr/local/bin/virtualenvwrapper.sh
    }

    export PATH=/usr/local/bin:/usr/local/sbin:$PATH

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

    # setup virtualwrapper env
    source "/usr/local/bin/virtualenvwrapper.sh"
    export WORKON_HOME=~/Envs