Skip to content

Instantly share code, notes, and snippets.

@ericrallen
Created October 5, 2015 20:48
Show Gist options
  • Select an option

  • Save ericrallen/9186f8db68cd7bfd1b5a to your computer and use it in GitHub Desktop.

Select an option

Save ericrallen/9186f8db68cd7bfd1b5a to your computer and use it in GitHub Desktop.

Revisions

  1. Eric Allen created this gist Oct 5, 2015.
    4 changes: 4 additions & 0 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # Load the .bashrc configuration whenever .bash_profile (this file) is sourced
    if [ -f ~/.bashrc ]; then
    source ~/.bashrc
    fi
    92 changes: 92 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    #bash profile settings for @allenericr

    #git completions
    source `brew --prefix git`/etc/bash_completion.d/git-completion.bash

    #user-specific stuff
    PATH="/usr/local/bin:/usr/local/sbin:$PATH:$HOME/bin"

    #git achievements
    PATH="$PATH:$HOME/git/git-achievements"

    # NODE Js
    NODE_PATH="/usr/local/bin"

    NODE_PATH="$NODE_PATH:/usr/local/lib/node_modules"

    #use SublimeText as editor
    EDITOR='sublime -w'

    #lazy git
    alias g='git'

    # Autocomplete for 'g' as well
    complete -o default -o nospace -F _git g

    #forgot a sudo? redo!
    alias redo=' sudo $(history -p \!\!)'

    # copy ssh key
    alias getssh=' pbcopy < ~/.ssh/id_rsa.pub'

    # cd into directory and ls it
    function cdl() {
    cd $1;
    ls;
    }

    # make a directory and cd into it in one command
    function mdir () {
    mkdir -p "$@" && eval cd "\"\$$#\"";
    }

    # Install a grunt plugin and save to devDependencies
    function gi() {
    npm install --save-dev grunt-"$@";
    }
    # borrowed from: http://chrisawren.com/posts/Advanced-Grunt-tooling

    # Install a grunt-contrib plugin and save to devDependencies
    function gci() {
    npm install --save-dev grunt-contrib-"$@";
    }
    #borrowed from: http://chrisawren.com/posts/Advanced-Grunt-tooling

    # Set Colours for Folders
    export CLICOLOR=1
    export LSCOLORS=DxExFxFxfxaxaxaxaxaxax

    # Prompt formatter
    function parse_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
    }

    function parse_git_status {
    # check if we're in a git repo
    is_git=`git status 2> /dev/null`

    if [ -z "$is_git" ] ; then
    return 1
    fi

    # check if there are changes
    status=`git status 2> /dev/null | grep "nothing to commit"`
    dirty_marker="Δ"

    if [ "$status" != "nothing to commit, working directory clean" ] ; then
    echo " $dirty_marker"
    fi
    }

    function format_prompt {
    local GREEN="\[\e[32m\]"
    local RED="\[\033[1;31m\]"
    local CYAN="\[\033[1;36m\]"
    local DEFAULT="\[\033[0m\]"
    local BLUE="\[\033[0;34m\]"
    local YELLOWBOLD="\[\033[1;33m\]"

    export PS1="$CYAN\n\w$GREEN\$(parse_git_branch)$YELLOWBOLD\$(parse_git_status)$RED\n> $DEFAULT"
    }

    format_prompt