Skip to content

Instantly share code, notes, and snippets.

@phlco
Last active December 23, 2015 17:39

Revisions

  1. phlco revised this gist Jul 31, 2014. 1 changed file with 125 additions and 255 deletions.
    380 changes: 125 additions & 255 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,17 @@
    # | |_) | (_| \__ \ | | | | |_) | | | (_) | _| | | __/
    # |_.__/ \__,_|___/_| |_| | .__/|_| \___/|_| |_|_|\___|
    # |_|

    # When Bash starts, it executes the commands in this script
    # http://en.wikipedia.org/wiki/Bash_(Unix_shell)
    #
    # Written by Phillip Lamplugh, Instructor General Assembly (2013)
    # Updated by PJ Hughes, Instructor General Assembly (2013)

    # Written by Philip Lamplugh, Instructor General Assembly (2013)
    # Updated by PJ Hughes, Instructor General Assembly (2013)

    # =====================
    # Resources
    # =====================

    # http://cli.learncodethehardway.org/bash_cheat_sheet.pdf
    # http://ss64.com/bash/syntax-prompt.html
    # https://dougbarton.us/Bash/Bash-prompts.html
    @@ -24,321 +26,189 @@
    # --------------------
    # System Settings
    # --------------------
    # 1. Path List
    # 2. File Navigation
    # 3. History
    # 4. Bash Prompt
    # 5. Other System Settings
    # Path List
    # Settings
    # History
    # Aliases
    # Other System Settings
    # --------------------
    # Application Settings
    # --------------------
    # 6. Application Aliases
    # 7. Sublime
    # 8. Git
    # 9. Rails
    # 10. rbenv
    # Application Aliases
    # rbenv
    # --------------------
    # Other Settings
    # --------------------
    # 11. Shortcuts
    # 12. Source Files
    # 13. Reserved


    # SYSTEM SETTINGS
    ##########################################################################
    # Shortcuts
    # Source Files
    # Environmental Variables and API Keys
    # Colophon

    # ==================
    # -----------------------------------------------------------------------------
    # Path
    # This is a list of all directories in which to look for commands, scripts and programs
    # ==================
    # A list of all directories in which to look for commands, scripts and programs
    # -----------------------------------------------------------------------------

    PATH="/usr/local/share/npm/bin:$PATH" # NPM
    PATH="/usr/local/bin:/usr/local/sbin:$PATH" # Homebrew
    PATH="/usr/local/heroku/bin:$PATH" # Heroku Toolbelt
    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" # Coreutils
    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" # Manual pages

    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Heroku Toolbelt
    PATH="/usr/local/heroku/bin:$PATH"
    # =================
    # Settings
    # =================

    # ====================
    # File Navigation
    # ====================
    # LS lists information about files. -F includes a slash for directories.
    alias ls='ls -F'
    # long list format including hidden files
    alias ll='ls -la'
    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    # Describes what color to use for which attribute (files, folders etc.)
    export LSCOLORS=faexcxdxbxegedabagacad # PJ: turned off
    # go back one directory
    alias b='cd ..'
    # If we make a change to our bash profile we need to reload it
    alias reload="clear; source ~/.bash_profile"
    ## Tab improvements
    ## Might not need?
    bind 'set completion-ignore-case on'
    # make completions appear immediately after pressing TAB once
    bind 'set show-all-if-ambiguous on'
    bind 'TAB: menu-complete'
    # Prefer US English
    export LC_ALL="en_US.UTF-8"
    # use UTF-8
    export LANG="en_US"
    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    # Describes what color to use for which attribute (files, folders etc.)
    export LSCOLORS=exfxcxdxbxegedabagacad # PJ: turned off

    # =================
    # History
    # =================
    # History lists your previously entered commands
    alias h='history'

    # http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/
    # Larger bash history (allow 32³ entries; default is 500)
    export HISTSIZE=32768
    export HISTFILESIZE=$HISTSIZE

    # don't put duplicate lines in the history.
    export HISTCONTROL=ignoredups

    # ignore same sucessive entries.
    export HISTCONTROL=ignoreboth

    # Make some commands not show up in history
    export HISTIGNORE="h:ls:ls *:ll:ll *:"

    export EDITOR="subl -w"
    # ====================
    # Aliases
    # ====================

    # LS lists information about files.
    # show slashes for directories.
    alias ls='ls -F'

    # long list format including hidden files and include unit size
    alias ll='ls -la'

    # go back one directory
    alias ..='cd ..'

    # History lists your previously entered commands
    alias h='history'

    # If we make a change to our bash profile we need to reload it
    alias reload="clear; source ~/.bash_profile"

    # confirm before executing and be verbose
    alias cp='cp -iv'
    alias mv='mv -iv'
    alias rm='rm -iv'
    alias mkdir='mkdir -pv'

    # =================
    # Other System Settings
    # Additional Aliases
    # =================

    # Hide/show all desktop icons (useful when presenting)
    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 hide_desktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
    alias show_desktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

    # Hide/show hidden files in Finder
    alias hidefiles="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder"
    alias showfiles="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder"
    # Start an HTTP server from a directory, optionally specifying the port
    function server() {
    local port="${1:-8000}"
    open "http://localhost:${port}/"
    # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
    # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
    python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
    }
    # List any open internet sockets on port 3000. Useful if a rogue server is running
    alias hide_files="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder"
    alias show_files="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder"

    # List any open internet sockets on several popular ports.
    # Useful if a rogue server is running
    # http://www.akadia.com/services/lsof_intro.html
    alias rogue='lsof -i TCP:3000'
    # http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
    alias rogue='lsof -i TCP:3000 -i TCP:4567 -i TCP:8000 -i TCP:8888 -i TCP:6379 -i TCP:5858 -i TCP:8080'

    # APPLICATION SETTINGS
    ##########################################################################

    # ================
    # Application Aliases
    # ================
    alias mou="open /Applications/Mou.app"
    alias hipchat="open /Applications/HipChat.app"

    # ================
    # Sublime
    # ================
    # Make sublime our editor of choice
    export EDITOR="subl -w"
    alias mou='open -a "Mou"'
    alias hipchat='open -a "HipChat"'
    alias chrome='open -a "Google Chrome"'
    # Sublime should be symlinked. Otherwise use one of these
    # alias subl='open -a "Sublime Text"'
    # alias subl='open -a "Sublime Text 2"'

    # =================
    # Git
    # rbenv
    # =================
    # -----------------
    # Aliases
    # -----------------
    # Alias for hub http://hub.github.com/
    alias git='hub'
    # Undo a git push
    alias undopush="git push -f origin HEAD^:master"
    # undo a commit
    alias uncommit="git reset --soft HEAD^"
    # -----------------
    # For the prompt
    # -----------------
    # Long git to show + ? !
    is_git_repo() {
    $(git rev-parse --is-inside-work-tree &> /dev/null)
    }
    is_git_dir() {
    $(git rev-parse --is-inside-git-dir 2> /dev/null)
    }
    get_git_branch() {
    local branch_name
    # Get the short symbolic ref
    branch_name=$(git symbolic-ref --quiet --short HEAD 2> /dev/null) ||
    # If HEAD isn't a symbolic ref, get the short SHA
    branch_name=$(git rev-parse --short HEAD 2> /dev/null) ||
    # Otherwise, just give up
    branch_name="(unknown)"
    printf $branch_name
    }
    # Git status information
    prompt_git() {
    local git_info git_state uc us ut st
    if ! is_git_repo || is_git_dir; then
    return 1
    fi
    git_info=$(get_git_branch)
    # Check for uncommitted changes in the index
    if ! $(git diff --quiet --ignore-submodules --cached); then
    uc="+"
    fi
    # Check for unstaged changes
    if ! $(git diff-files --quiet --ignore-submodules --); then
    us="!"
    fi
    # Check for untracked files
    if [ -n "$(git ls-files --others --exclude-standard)" ]; then
    ut="${RED}?"
    fi
    # Check for stashed files
    if $(git rev-parse --verify refs/stash &>/dev/null); then
    st="$"
    fi
    git_state=$uc$us$ut$st
    # Combine the branch name and state information
    if [[ $git_state ]]; then
    git_info="$git_info${RESET}[$git_state${RESET}]"
    fi
    printf "${WHITE} on ${style_branch}${git_info}"
    }

    # =================
    # Rails
    # =================
    # Migrate Dev and Test databases and annotate models
    alias migrate='rake db:migrate; rake db:migrate RAILS_ENV=test; annotate'
    # start rbenv (our Ruby environment and version manager) on open
    eval "$(rbenv init -)"

    # =================
    # rbenv
    # Functions
    # =================
    # start rbenv (our Ruby environment and version manager) on open
    eval "$(rbenv init -)"

    # Other Settings
    ##########################################################################
    #######################################
    # Start an HTTP server from a directory
    # Arguments:
    # Port (optional)
    #######################################

    server() {
    local port="${1:-8000}"
    open "http://localhost:${port}/"
    # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
    # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
    python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
    }

    # =================
    # Shortcuts
    # Tab Improvements
    # =================
    # Students can add a shortcut to quickly access their GA folder
    # example: alias wdi="cd ~/Documents/GA/WDI4"

    alias wdi="cd ~/dev/wdi/WDI_NYC_12_Students"
    cdhwfunc() {
    # takes three args: the week, the day
    # and an optional third for the user
    if [ $1 -lt 10 ]
    then
    cd ~/dev/wdi/WDI_NYC_12_Students/w0$1/d0$2/${3:-Instructor}
    else
    cd ~/dev/wdi/WDI_NYC_12_Students/w$1/d0$2/${3:-Instructor}
    fi
    }
    alias cdhw=cdhwfunc

    ## Tab improvements
    # ## Might not need?
    # bind 'set completion-ignore-case on'
    # # make completions appear immediately after pressing TAB once
    # bind 'set show-all-if-ambiguous on'
    # bind 'TAB: menu-complete'

    # =================
    # Source Files
    # Sourced Scripts
    # =================

    # .bash_settings and .bash_prompt should be added to .gitignore_global
    # An extra file where you can create other settings, such as your
    # application usernames or API keys...
    if [ -f ~/.bash_settings ]; then
    source ~/.bash_settings
    fi
    # An extra file where you can create other settings for your prompt.
    # TODO(phlco): change to directory one liner
    # for f in ~/.bash_profile_*; do source $f; done

    # Builds the prompt with git branch notifications.
    if [ -f ~/.bash_prompt ]; then
    source ~/.bash_prompt
    fi

    # =================
    # Bash Prompt
    # =================
    # --------------------
    # Colors for the prompt
    # --------------------
    # Set the TERM var to xterm-256color
    if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
    export TERM=gnome-256color
    elif infocmp xterm-256color >/dev/null 2>&1; then
    export TERM=xterm-256color
    # A welcome prompt with stats for sanity checks
    if [ -f ~/.welcome_prompt ]; then
    source ~/.welcome_prompt
    fi
    if tput setaf 1 &> /dev/null; then
    tput sgr0
    if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
    # this is for xterm-256color
    BLACK=$(tput setaf 0)
    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    YELLOW=$(tput setaf 226)
    BLUE=$(tput setaf 4)
    MAGENTA=$(tput setaf 5)
    CYAN=$(tput setaf 6)
    WHITE=$(tput setaf 7)
    ORANGE=$(tput setaf 172)
    # GREEN=$(tput setaf 190)
    PURPLE=$(tput setaf 141)
    BG_BLACK=$(tput setab 0)
    BG_RED=$(tput setab 1)
    BG_GREEN=$(tput setab 2)
    BG_BLUE=$(tput setab 4)
    BG_MAGENTA=$(tput setab 5)
    BG_CYAN=$(tput setab 6)
    BG_YELLOW=$(tput setab 226)
    BG_ORANGE=$(tput setab 172)
    BG_WHITE=$(tput setab 7)
    else
    MAGENTA=$(tput setaf 5)
    ORANGE=$(tput setaf 4)
    GREEN=$(tput setaf 2)
    PURPLE=$(tput setaf 1)
    WHITE=$(tput setaf 7)
    fi
    BOLD=$(tput bold)
    RESET=$(tput sgr0)
    UNDERLINE=$(tput sgr 0 1)
    else
    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"

    # bash/zsh completion support for core Git.
    if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
    fi
    # ---------------------
    # Print Stats on terminal load
    # ---------------------
    # GA General Assembly Webdevelopment Immersive
    echo ${BG_RED}${WHITE}GA${RESET}${WHITE}${BG_BLACK} General Assembly ${RESET}${BG_YELLOW}${BLACK} Web Development Immersive ${RESET}
    echo "------------------------------------------"
    echo $(ruby -v)
    echo $(rails -v)
    echo $(git --version)
    echo $(heroku --version)
    echo $(psql --version)
    echo $(brew -v)
    echo "------------------------------------------"
    # ---------------------
    # style the prompt
    # ---------------------
    style_user="\[${RESET}${WHITE}\]"
    style_path="\[${RESET}${CYAN}\]"
    style_chars="\[${RESET}${WHITE}\]"
    style_branch="${RED}"
    # ---------------------
    # Build the prompt
    # ---------------------
    # Example with committed changes: username ~/documents/GA/wdi on master[+]
    PS1="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)

    # ====================================
    # Environmental Variables and API Keys
    # ====================================

    # Below here is an area for other commands added by outside programs or
    # commands. Attempt to reserve this area for their use!
    ##########################################################################
    if [ -f ~/.extra ]; then
    source ~/.extra
    fi
  2. phlco revised this gist Jan 10, 2014. 1 changed file with 256 additions and 74 deletions.
    330 changes: 256 additions & 74 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,93 +1,158 @@
    # __ ___ __ ______ __ ___ __ __ ___ _______. __ __
    # | |/ / | | / || |/ / | | | | / \ / || | | |
    # | ' / | | | ,----'| ' / | |__| | / ^ \ | (----`| |__| |
    # | < | | | | | < | __ | / /_\ \ \ \ | __ |
    # | . \ | | | `----.| . \ | | | | / _____ \ .----) | | | | |
    # |__|\__\ |__| \______||__|\__\ |__| |__| /__/ \__\ |_______/ |__| |__|
    # _ _ __ _ _
    # | |__ __ _ ___| |__ _ __ _ __ ___ / _(_) | ___
    # | '_ \ / _` / __| '_ \ | '_ \| '__/ _ \| |_| | |/ _ \
    # | |_) | (_| \__ \ | | | | |_) | | | (_) | _| | | __/
    # |_.__/ \__,_|___/_| |_| | .__/|_| \___/|_| |_|_|\___|
    # |_|
    # When Bash starts, it executes the commands in this script
    # http://en.wikipedia.org/wiki/Bash_(Unix_shell)
    #
    # Written by Phillip Lamplugh, Instructor General Assembly (2013)
    # Updated by PJ Hughes, Instructor General Assembly (2013)

    # instructions
    # subl ~/.bash_profile to open your bash profile in Sublime
    # =====================
    # Resources
    # =====================
    # http://cli.learncodethehardway.org/bash_cheat_sheet.pdf
    # http://ss64.com/bash/syntax-prompt.html
    # https://dougbarton.us/Bash/Bash-prompts.html
    # http://sage.ucsc.edu/xtal/iterm_tab_customization.html

    # We're about to copy and paste this over. Ok cool, BUT WAIT!
    # Do you have any pre-existing settings in your bash_profile? Maybe we should make a back up
    # ====================
    # TOC
    # ====================
    # --------------------
    # System Settings
    # --------------------
    # 1. Path List
    # 2. File Navigation
    # 3. History
    # 4. Bash Prompt
    # 5. Other System Settings
    # --------------------
    # Application Settings
    # --------------------
    # 6. Application Aliases
    # 7. Sublime
    # 8. Git
    # 9. Rails
    # 10. rbenv
    # --------------------
    # Other Settings
    # --------------------
    # 11. Shortcuts
    # 12. Source Files
    # 13. Reserved

    # cp ~/.bash_profile ~/.bash_profile_backup

    # PHEW
    # SYSTEM SETTINGS
    ##########################################################################

    # Copy and paste this bash_profile into your ~/.bash_profile
    # ==================
    # Path
    # This is a list of all directories in which to look for commands, scripts and programs
    # ==================

    # source ~/.bash_profile to reload your profile

    # ---------------------
    # Tab improvements
    # ---------------------
    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Heroku Toolbelt
    PATH="/usr/local/heroku/bin:$PATH"

    # ====================
    # File Navigation
    # ====================
    # LS lists information about files. -F includes a slash for directories.
    alias ls='ls -F'
    # long list format including hidden files
    alias ll='ls -la'
    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    # Describes what color to use for which attribute (files, folders etc.)
    export LSCOLORS=faexcxdxbxegedabagacad # PJ: turned off
    # go back one directory
    alias b='cd ..'
    # If we make a change to our bash profile we need to reload it
    alias reload="clear; source ~/.bash_profile"
    ## Tab improvements
    ## Might not need?
    bind 'set completion-ignore-case on'
    # make completions appear immediately after pressing TAB once
    bind 'set show-all-if-ambiguous on'
    bind 'TAB: menu-complete'
    # Prefer US English
    export LC_ALL="en_US.UTF-8"
    # use UTF-8
    export LANG="en_US"

    # ---------------------
    # =================
    # History
    # ---------------------

    # =================
    # History lists your previously entered commands
    alias h='history'
    # http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/
    # Larger bash history (allow 32³ entries; default is 500)
    export HISTSIZE=32768
    export HISTFILESIZE=$HISTSIZE
    # don't put duplicate lines in the history.
    export HISTCONTROL=ignoredups
    # ignore same sucessive entries.
    export HISTCONTROL=ignoreboth
    # Make some commands not show up in history
    export HISTIGNORE="h:ls:ls *:ll:ll *:"

    # ---------------------
    # Path
    # ---------------------
    # =================
    # Other System Settings
    # =================
    # Hide/show all desktop icons (useful when presenting)
    alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
    alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
    # Hide/show hidden files in Finder
    alias hidefiles="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder"
    alias showfiles="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder"
    # Start an HTTP server from a directory, optionally specifying the port
    function server() {
    local port="${1:-8000}"
    open "http://localhost:${port}/"
    # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
    # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
    python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
    }
    # List any open internet sockets on port 3000. Useful if a rogue server is running
    # http://www.akadia.com/services/lsof_intro.html
    alias rogue='lsof -i TCP:3000'

    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Make sure we're pointing to the Postgres App's psql
    PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
    # APPLICATION SETTINGS
    ##########################################################################

    # ---------------------
    # Sublime
    # ---------------------
    # ================
    # Application Aliases
    # ================
    alias mou="open /Applications/Mou.app"
    alias hipchat="open /Applications/HipChat.app"

    # ================
    # Sublime
    # ================
    # Make sublime our editor of choice
    export EDITOR="subl -w"

    # -----------------------
    # Alias
    # ------------------------

    # Open files with Sublime
    alias subl='open -a "Sublime Text 2"'
    alias ll='ls -fa'
    alias reload="source ~/.bash_profile"
    alias b="cd .."
    # prompt before deleting!
    alias rm="rm -i"

    # ---------------------
    # Colors
    # ---------------------

    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    export LSCOLORS=bxexcxdxbxegedabagacad
    # prompt colors
    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"

    # =================
    # Git
    # =================
    # -----------------
    # Git status in the prompt
    # Aliases
    # -----------------
    # Alias for hub http://hub.github.com/
    alias git='hub'
    # Undo a git push
    alias undopush="git push -f origin HEAD^:master"
    # undo a commit
    alias uncommit="git reset --soft HEAD^"
    # -----------------
    # For the prompt
    # -----------------

    # Long git to show + ? !
    is_git_repo() {
    $(git rev-parse --is-inside-work-tree &> /dev/null)
    @@ -105,10 +170,7 @@ get_git_branch() {
    branch_name="(unknown)"
    printf $branch_name
    }

    # ---------------------
    # Git status information
    # ---------------------
    prompt_git() {
    local git_info git_state uc us ut st
    if ! is_git_repo || is_git_dir; then
    @@ -139,24 +201,144 @@ prompt_git() {
    printf "${WHITE} on ${style_branch}${git_info}"
    }

    #----------------------
    # =================
    # Rails
    # =================
    # Migrate Dev and Test databases and annotate models
    alias migrate='rake db:migrate; rake db:migrate RAILS_ENV=test; annotate'

    # =================
    # rbenv
    # =================
    # start rbenv (our Ruby environment and version manager) on open
    eval "$(rbenv init -)"

    # Other Settings
    ##########################################################################

    # =================
    # Shortcuts
    # =================
    # Students can add a shortcut to quickly access their GA folder
    # example: alias wdi="cd ~/Documents/GA/WDI4"

    alias wdi="cd ~/dev/wdi/WDI_NYC_12_Students"
    cdhwfunc() {
    # takes three args: the week, the day
    # and an optional third for the user
    if [ $1 -lt 10 ]
    then
    cd ~/dev/wdi/WDI_NYC_12_Students/w0$1/d0$2/${3:-Instructor}
    else
    cd ~/dev/wdi/WDI_NYC_12_Students/w$1/d0$2/${3:-Instructor}
    fi
    }
    alias cdhw=cdhwfunc

    # =================
    # Source Files
    # =================

    # .bash_settings and .bash_prompt should be added to .gitignore_global
    # An extra file where you can create other settings, such as your
    # application usernames or API keys...
    if [ -f ~/.bash_settings ]; then
    source ~/.bash_settings
    fi
    # An extra file where you can create other settings for your prompt.
    if [ -f ~/.bash_prompt ]; then
    source ~/.bash_prompt
    fi

    # =================
    # Bash Prompt
    # =================
    # --------------------
    # Colors for the prompt
    # --------------------
    # Set the TERM var to xterm-256color
    if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
    export TERM=gnome-256color
    elif infocmp xterm-256color >/dev/null 2>&1; then
    export TERM=xterm-256color
    fi
    if tput setaf 1 &> /dev/null; then
    tput sgr0
    if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
    # this is for xterm-256color
    BLACK=$(tput setaf 0)
    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    YELLOW=$(tput setaf 226)
    BLUE=$(tput setaf 4)
    MAGENTA=$(tput setaf 5)
    CYAN=$(tput setaf 6)
    WHITE=$(tput setaf 7)
    ORANGE=$(tput setaf 172)
    # GREEN=$(tput setaf 190)
    PURPLE=$(tput setaf 141)
    BG_BLACK=$(tput setab 0)
    BG_RED=$(tput setab 1)
    BG_GREEN=$(tput setab 2)
    BG_BLUE=$(tput setab 4)
    BG_MAGENTA=$(tput setab 5)
    BG_CYAN=$(tput setab 6)
    BG_YELLOW=$(tput setab 226)
    BG_ORANGE=$(tput setab 172)
    BG_WHITE=$(tput setab 7)
    else
    MAGENTA=$(tput setaf 5)
    ORANGE=$(tput setaf 4)
    GREEN=$(tput setaf 2)
    PURPLE=$(tput setaf 1)
    WHITE=$(tput setaf 7)
    fi
    BOLD=$(tput bold)
    RESET=$(tput sgr0)
    UNDERLINE=$(tput sgr 0 1)
    else
    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"
    fi
    # ---------------------
    # Print Stats on terminal load
    # ---------------------
    # GA General Assembly Webdevelopment Immersive
    echo ${BG_RED}${WHITE}GA${RESET}${WHITE}${BG_BLACK} General Assembly ${RESET}${BG_YELLOW}${BLACK} Web Development Immersive ${RESET}
    echo "------------------------------------------"
    echo $(ruby -v)
    echo $(rails -v)
    echo $(git --version)
    echo $(heroku --version)
    echo $(psql --version)
    echo $(brew -v)
    echo "------------------------------------------"
    # ---------------------
    # style the prompt
    # ---------------------
    style_user="\[${RESET}${WHITE}\]"
    style_path="\[${RESET}${CYAN}\]"
    style_chars="\[${RESET}${WHITE}\]"
    style_branch="${RED}"

    # ---------------------
    # Build the prompt
    # ---------------------
    # Example with committed changes: username ~/documents/GA/wdi on master[+]
    PS1=""
    PS1+="${style_user}\u" # Username
    PS1="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)

    # for rbenv
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
    # Below here is an area for other commands added by outside programs or
    # commands. Attempt to reserve this area for their use!
    ##########################################################################
  3. phlco revised this gist Sep 23, 2013. 1 changed file with 34 additions and 12 deletions.
    46 changes: 34 additions & 12 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,28 +1,44 @@
    # __ ___ __ ______ __ ___ __ __ ___ _______. __ __ __
    # | |/ / | | / || |/ / | | | | / \ / || | | | | |
    # | ' / | | | ,----'| ' / | |__| | / ^ \ | (----`| |__| | | |
    # | < | | | | | < | __ | / /_\ \ \ \ | __ | | |
    # | . \ | | | `----.| . \ | | | | / _____ \ .----) | | | | | |__|
    # |__|\__\ |__| \______||__|\__\ |__| |__| /__/ \__\ |_______/ |__| |__| (__)
    #

    # __ ___ __ ______ __ ___ __ __ ___ _______. __ __
    # | |/ / | | / || |/ / | | | | / \ / || | | |
    # | ' / | | | ,----'| ' / | |__| | / ^ \ | (----`| |__| |
    # | < | | | | | < | __ | / /_\ \ \ \ | __ |
    # | . \ | | | `----.| . \ | | | | / _____ \ .----) | | | | |
    # |__|\__\ |__| \______||__|\__\ |__| |__| /__/ \__\ |_______/ |__| |__|

    # instructions
    # subl ~/.bash_profile to open your bash profile in Sublime

    # We're about to copy and paste this over. Ok cool, BUT WAIT!
    # Do you have any pre-existing settings in your bash_profile? Maybe we should make a back up

    # cp ~/.bash_profile ~/.bash_profile_backup

    # PHEW

    # Copy and paste this bash_profile into your ~/.bash_profile

    # source ~/.bash_profile to reload your profile

    # ---------------------
    # Tab improvements
    # ---------------------

    bind 'set completion-ignore-case on'
    bind 'set show-all-if-ambiguous on'
    bind 'TAB: menu-complete'

    # ---------------------
    # History
    # ---------------------

    # Larger bash history (allow 32³ entries; default is 500)
    export HISTSIZE=32768
    export HISTFILESIZE=$HISTSIZE

    # ---------------------
    # Path
    # ---------------------

    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Make sure we're pointing to the Postgres App's psql
    @@ -31,23 +47,26 @@ PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
    # ---------------------
    # Sublime
    # ---------------------

    # Make sublime our editor of choice
    export EDITOR="subl -w"

    # -----------------------
    # Alias
    # ------------------------

    # Open files with Sublime
    alias subl='open -a "Sublime Text"'
    alias subl='open -a "Sublime Text 2"'
    alias ll='ls -fa'
    alias reload="source ~/.bash_profile"
    alias b="cd .."
    alias h="history"

    # prompt before deleting!
    alias rm="rm -i"

    # ---------------------
    # Colors
    # ---------------------

    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    @@ -137,4 +156,7 @@ PS1+="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)

    # for rbenv
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
  4. phlco revised this gist Sep 23, 2013. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    # __ ___ __ ______ __ ___ __ __ ___ _______. __ __ __
    # | |/ / | | / || |/ / | | | | / \ / || | | | | |
    # | ' / | | | ,----'| ' / | |__| | / ^ \ | (----`| |__| | | |
    # | < | | | | | < | __ | / /_\ \ \ \ | __ | | |
    # | . \ | | | `----.| . \ | | | | / _____ \ .----) | | | | | |__|
    # |__|\__\ |__| \______||__|\__\ |__| |__| /__/ \__\ |_______/ |__| |__| (__)
    #

    # ---------------------
    # Tab improvements
    # ---------------------
    @@ -8,15 +16,13 @@ bind 'TAB: menu-complete'
    # ---------------------
    # History
    # ---------------------

    # Larger bash history (allow 32³ entries; default is 500)
    export HISTSIZE=32768
    export HISTFILESIZE=$HISTSIZE

    # ---------------------
    # Path
    # ---------------------

    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Make sure we're pointing to the Postgres App's psql
    @@ -25,7 +31,6 @@ PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
    # ---------------------
    # Sublime
    # ---------------------

    # Make sublime our editor of choice
    export EDITOR="subl -w"

    @@ -37,12 +42,12 @@ alias subl='open -a "Sublime Text"'
    alias ll='ls -fa'
    alias reload="source ~/.bash_profile"
    alias b="cd .."
    alias h="history"


    # ---------------------
    # Colors
    # ---------------------

    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
  5. phlco revised this gist Sep 23, 2013. 1 changed file with 94 additions and 0 deletions.
    94 changes: 94 additions & 0 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -28,8 +28,16 @@ PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

    # Make sublime our editor of choice
    export EDITOR="subl -w"

    # -----------------------
    # Alias
    # ------------------------
    # Open files with Sublime
    alias subl='open -a "Sublime Text"'
    alias ll='ls -fa'
    alias reload="source ~/.bash_profile"
    alias b="cd .."


    # ---------------------
    # Colors
    @@ -39,3 +47,89 @@ alias subl='open -a "Sublime Text"'
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    export LSCOLORS=bxexcxdxbxegedabagacad
    # prompt colors
    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"

    # -----------------
    # Git status in the prompt
    # -----------------

    # Long git to show + ? !
    is_git_repo() {
    $(git rev-parse --is-inside-work-tree &> /dev/null)
    }
    is_git_dir() {
    $(git rev-parse --is-inside-git-dir 2> /dev/null)
    }
    get_git_branch() {
    local branch_name
    # Get the short symbolic ref
    branch_name=$(git symbolic-ref --quiet --short HEAD 2> /dev/null) ||
    # If HEAD isn't a symbolic ref, get the short SHA
    branch_name=$(git rev-parse --short HEAD 2> /dev/null) ||
    # Otherwise, just give up
    branch_name="(unknown)"
    printf $branch_name
    }

    # ---------------------
    # Git status information
    # ---------------------
    prompt_git() {
    local git_info git_state uc us ut st
    if ! is_git_repo || is_git_dir; then
    return 1
    fi
    git_info=$(get_git_branch)
    # Check for uncommitted changes in the index
    if ! $(git diff --quiet --ignore-submodules --cached); then
    uc="+"
    fi
    # Check for unstaged changes
    if ! $(git diff-files --quiet --ignore-submodules --); then
    us="!"
    fi
    # Check for untracked files
    if [ -n "$(git ls-files --others --exclude-standard)" ]; then
    ut="${RED}?"
    fi
    # Check for stashed files
    if $(git rev-parse --verify refs/stash &>/dev/null); then
    st="$"
    fi
    git_state=$uc$us$ut$st
    # Combine the branch name and state information
    if [[ $git_state ]]; then
    git_info="$git_info${RESET}[$git_state${RESET}]"
    fi
    printf "${WHITE} on ${style_branch}${git_info}"
    }

    #----------------------
    # style the prompt
    # ---------------------
    style_user="\[${RESET}${WHITE}\]"
    style_path="\[${RESET}${CYAN}\]"
    style_chars="\[${RESET}${WHITE}\]"
    style_branch="${RED}"

    # ---------------------
    # Build the prompt
    # ---------------------
    # Example with committed changes: username ~/documents/GA/wdi on master[+]
    PS1=""
    PS1+="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)
  6. phlco revised this gist Sep 23, 2013. No changes.
  7. phlco revised this gist Sep 23, 2013. 1 changed file with 0 additions and 86 deletions.
    86 changes: 0 additions & 86 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -39,89 +39,3 @@ alias subl='open -a "Sublime Text"'
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    export LSCOLORS=bxexcxdxbxegedabagacad

    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"

    # -----------------
    # Git status in the prompt
    # -----------------

    # Long git to show + ? !
    is_git_repo() {
    $(git rev-parse --is-inside-work-tree &> /dev/null)
    }
    is_git_dir() {
    $(git rev-parse --is-inside-git-dir 2> /dev/null)
    }
    get_git_branch() {
    local branch_name
    # Get the short symbolic ref
    branch_name=$(git symbolic-ref --quiet --short HEAD 2> /dev/null) ||
    # If HEAD isn't a symbolic ref, get the short SHA
    branch_name=$(git rev-parse --short HEAD 2> /dev/null) ||
    # Otherwise, just give up
    branch_name="(unknown)"
    printf $branch_name
    }

    # ---------------------
    # Git status information
    # ---------------------
    prompt_git() {
    local git_info git_state uc us ut st
    if ! is_git_repo || is_git_dir; then
    return 1
    fi
    git_info=$(get_git_branch)
    # Check for uncommitted changes in the index
    if ! $(git diff --quiet --ignore-submodules --cached); then
    uc="+"
    fi
    # Check for unstaged changes
    if ! $(git diff-files --quiet --ignore-submodules --); then
    us="!"
    fi
    # Check for untracked files
    if [ -n "$(git ls-files --others --exclude-standard)" ]; then
    ut="${RED}?"
    fi
    # Check for stashed files
    if $(git rev-parse --verify refs/stash &>/dev/null); then
    st="$"
    fi
    git_state=$uc$us$ut$st
    # Combine the branch name and state information
    if [[ $git_state ]]; then
    git_info="$git_info${RESET}[$git_state${RESET}]"
    fi
    printf "${WHITE} on ${style_branch}${git_info}"
    }

    #----------------------
    # style the prompt
    # ---------------------
    style_user="\[${RESET}${WHITE}\]"
    style_path="\[${RESET}${CYAN}\]"
    style_chars="\[${RESET}${WHITE}\]"
    style_branch="${RED}"

    # ---------------------
    # Build the prompt
    # ---------------------
    # Example with committed changes: username ~/documents/GA/wdi on master[+]
    PS1=""
    PS1+="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)
  8. phlco created this gist Sep 23, 2013.
    127 changes: 127 additions & 0 deletions bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,127 @@
    # ---------------------
    # Tab improvements
    # ---------------------
    bind 'set completion-ignore-case on'
    bind 'set show-all-if-ambiguous on'
    bind 'TAB: menu-complete'

    # ---------------------
    # History
    # ---------------------

    # Larger bash history (allow 32³ entries; default is 500)
    export HISTSIZE=32768
    export HISTFILESIZE=$HISTSIZE

    # ---------------------
    # Path
    # ---------------------

    # Home brew directories
    PATH="/usr/local/bin:$PATH"
    # Make sure we're pointing to the Postgres App's psql
    PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

    # ---------------------
    # Sublime
    # ---------------------

    # Make sublime our editor of choice
    export EDITOR="subl -w"
    # Open files with Sublime
    alias subl='open -a "Sublime Text"'

    # ---------------------
    # Colors
    # ---------------------

    # Adds colors to LS
    export CLICOLOR=1
    # http://geoff.greer.fm/lscolors/
    export LSCOLORS=bxexcxdxbxegedabagacad

    BLACK="\[\e[0;30m\]"
    RED="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    YELLOW="\[\e[0;33m\]"
    CYAN="\[\e[0;36m\]"
    BLUE="\[\e[0;34m\]"
    BOLD=""
    RESET="\033[m"

    # -----------------
    # Git status in the prompt
    # -----------------

    # Long git to show + ? !
    is_git_repo() {
    $(git rev-parse --is-inside-work-tree &> /dev/null)
    }
    is_git_dir() {
    $(git rev-parse --is-inside-git-dir 2> /dev/null)
    }
    get_git_branch() {
    local branch_name
    # Get the short symbolic ref
    branch_name=$(git symbolic-ref --quiet --short HEAD 2> /dev/null) ||
    # If HEAD isn't a symbolic ref, get the short SHA
    branch_name=$(git rev-parse --short HEAD 2> /dev/null) ||
    # Otherwise, just give up
    branch_name="(unknown)"
    printf $branch_name
    }

    # ---------------------
    # Git status information
    # ---------------------
    prompt_git() {
    local git_info git_state uc us ut st
    if ! is_git_repo || is_git_dir; then
    return 1
    fi
    git_info=$(get_git_branch)
    # Check for uncommitted changes in the index
    if ! $(git diff --quiet --ignore-submodules --cached); then
    uc="+"
    fi
    # Check for unstaged changes
    if ! $(git diff-files --quiet --ignore-submodules --); then
    us="!"
    fi
    # Check for untracked files
    if [ -n "$(git ls-files --others --exclude-standard)" ]; then
    ut="${RED}?"
    fi
    # Check for stashed files
    if $(git rev-parse --verify refs/stash &>/dev/null); then
    st="$"
    fi
    git_state=$uc$us$ut$st
    # Combine the branch name and state information
    if [[ $git_state ]]; then
    git_info="$git_info${RESET}[$git_state${RESET}]"
    fi
    printf "${WHITE} on ${style_branch}${git_info}"
    }

    #----------------------
    # style the prompt
    # ---------------------
    style_user="\[${RESET}${WHITE}\]"
    style_path="\[${RESET}${CYAN}\]"
    style_chars="\[${RESET}${WHITE}\]"
    style_branch="${RED}"

    # ---------------------
    # Build the prompt
    # ---------------------
    # Example with committed changes: username ~/documents/GA/wdi on master[+]
    PS1=""
    PS1+="${style_user}\u" # Username
    PS1+="${style_path} \w" # Working directory
    PS1+="\$(prompt_git)" # Git details
    PS1+="\n" # Newline
    PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)