elyseholladay
11/19/2014 - 10:02 PM

Elyse's bash profile

Elyse's bash profile

# set up Sublime as default editor and "subl ." command
export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH
export EDITOR='subl -w'

#!/usr/bin/env bash

# Make my prompt AWESOMESAUCE
__powerline() {

    # EMOJI YO
    GIT_BRANCH_SYMBOL='  '
    GIT_BRANCH_CHANGED_SYMBOL='❤️  '
    GIT_NEED_PUSH_SYMBOL='  '
    GIT_NEED_PULL_SYMBOL='  '

    # Solarized colorscheme
    FG_BASE03="\[$(tput setaf 8)\]"
    FG_BASE02="\[$(tput setaf 0)\]"
    FG_BASE01="\[$(tput setaf 10)\]"
    FG_BASE00="\[$(tput setaf 11)\]"
    FG_BASE0="\[$(tput setaf 12)\]"
    FG_BASE1="\[$(tput setaf 14)\]"
    FG_BASE2="\[$(tput setaf 7)\]"
    FG_BASE3="\[$(tput setaf 15)\]"

    BG_BASE03="\[$(tput setab 8)\]"
    BG_BASE02="\[$(tput setab 0)\]"
    BG_BASE01="\[$(tput setab 10)\]"
    BG_BASE00="\[$(tput setab 11)\]"
    BG_BASE0="\[$(tput setab 12)\]"
    BG_BASE1="\[$(tput setab 14)\]"
    BG_BASE2="\[$(tput setab 7)\]"
    BG_BASE3="\[$(tput setab 15)\]"

    FG_YELLOW="\[$(tput setaf 3)\]"
    FG_ORANGE="\[$(tput setaf 9)\]"
    FG_RED="\[$(tput setaf 1)\]"
    FG_MAGENTA="\[$(tput setaf 5)\]"
    FG_VIOLET="\[$(tput setaf 13)\]"
    FG_BLUE="\[$(tput setaf 4)\]"
    FG_CYAN="\[$(tput setaf 6)\]"
    FG_GREEN="\[$(tput setaf 2)\]"

    BG_YELLOW="\[$(tput setab 3)\]"
    BG_ORANGE="\[$(tput setab 9)\]"
    BG_RED="\[$(tput setab 1)\]"
    BG_MAGENTA="\[$(tput setab 5)\]"
    BG_VIOLET="\[$(tput setab 13)\]"
    BG_BLUE="\[$(tput setab 4)\]"
    BG_CYAN="\[$(tput setab 6)\]"
    BG_GREEN="\[$(tput setab 2)\]"

    DIM="\[$(tput dim)\]"
    REVERSE="\[$(tput rev)\]"
    RESET="\[$(tput sgr0)\]"
    BOLD="\[$(tput bold)\]"

    # git branching stuff for prompt which I stole from Flip Stewart
    # https://gist.github.com/flipstewart/2f5c01a019812d436076
    __git_branch() {
        [ -z "$(which git)" ] && return    # no git command found

        # try to get current branch or or SHA1 hash for detached head
        local branch="$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
        [ -z "$branch" ] && return  # not a git branch

        local marks

        # branch is modified
        [ -n "$(git status --porcelain)" ] && marks+="$GIT_BRANCH_CHANGED_SYMBOL"

        # check if local branch is ahead/behind of remote and by how many commits
        # Shamelessly copied from http://stackoverflow.com/questions/2969214/git-programmatically-know-by-how-much-the-branch-is-ahead-behind-a-remote-branc
        local remote="$(git config branch.$branch.remote)"
        local remote_ref="$(git config branch.$branch.merge)"
        local remote_branch="${remote_ref##refs/heads/}"
        local tracking_branch="refs/remotes/$remote/$remote_branch"
        if [ -n "$remote" ]; then
            local pushN="$(git rev-list $tracking_branch..HEAD|wc -l|tr -d ' ')"
            local pullN="$(git rev-list HEAD..$tracking_branch|wc -l|tr -d ' ')"
            [ "$pushN" != "0" ] && marks+=" $GIT_NEED_PUSH_SYMBOL$pushN"
            [ "$pullN" != "0" ] && marks+=" $GIT_NEED_PULL_SYMBOL$pullN"
        fi

        # print the git branch segment without a trailing newline
        printf "$GIT_BRANCH_SYMBOL$branch$marks "
    }

    # Actually the prompt output
    ps1() {
        # set green, print hostname up to first . ALSO EMOJI
        PS1="$FG_GREEN \h     "
        # set blue, print only current directory (not path), reset
        PS1+="$FG_BLUE at \W$RESET"
        # print git info from function above
        PS1+="$FG_VIOLET on $(__git_branch)"$RESET
        # date and time if you want it
        # PS1+=" \d \T"
        # PINK $ prompt
        PS1+="$FG_MAGENTA$ $RESET"
    }

    # print prompt
    PROMPT_COMMAND=ps1
    # make Terminal/iTerm tab print the name of the current directory
    PROMPT_COMMAND='echo -ne "\033]0; ${PWD##*/}\007"'
}

# idk
__powerline
unset __powerline


# ALIASES

# Git Aliases
alias status='git status'
alias checkout='git checkout'
alias commit='git commit'
alias rebase='git rebase'
alias branches='git branch -a'
alias add='git add -A'
alias pull='git pull'
alias push='git push'
alias log='git log --date-order --all --graph --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'

# refresh shell
alias reload='source ~/.bash_profile'

# folder aliases

alias rmn='cd ~/Documents/Projects/retailmenot'
alias blog='cd ~/Documents/Personal/elyseholladaydotcom'

# up 'n' folders
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'