216 lines · 6.4 KB
# Bash completion (via Homebrew)
[[ -f `brew --prefix`/etc/bash_completion ]] && . `brew --prefix`/etc/bash_completion

# Set the terminal into 256 color mode
export TERM=xterm-256color

# Variables for later
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
LAZY_VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper_lazy.sh
GIT_BASH_COMPLETION_SCRIPT=/usr/local/etc/bash_completion.d/git-completion.bash
BREW_BASH_COMPLETION_SCRIPT=/usr/local/etc/bash_completion.d/brew_bash_completion.sh

# Format the prompt
function prompt_func() {

    # Shorted the pwd in the prompt to show only the n number of characters
    # NOTE: Bash 4+ only
    PROMPT_DIRTRIM=2

    # Ascii color escape codes
    RED="\[\e[0;31m\]"
    GREEN="\[\e[0;32m\]"
    YELLOW="\[\e[0;33m\]"
    BLUE="\[\e[0;34m\]"
    PURPLE="\[\e[0;35m\]"
    CYAN="\[\e[0;36m\]"
    LIGHT_GREEN="\[\e[1;32m\]"
    WHITE="\[\e[1;37m\]"
    LIGHT_GRAY="\[\e[0;37m\]"
    COLOR_NONE="\[\e[0m\]"

    # 256 color foreground codes follow the following format:
    # SAMPLE_256_COLOR="\[\e[38;05;255m\]"

    # Show Git branch in prompt
    if [ -f $GIT_BASH_COMPLETION_SCRIPT ]; then
        export GIT_PS1_SHOWDIRTYSTATE=true
        export GIT_PS1_SHOWUNTRACKEDFILES=true
        export GIT_PS1_SHOWSTASHSTATE=true
        git_branch=$(__git_ps1 " (%s)")