Last active
August 29, 2015 14:25
-
-
Save MattMcFarland/6a480267e41bf5405bf3 to your computer and use it in GitHub Desktop.
A sexy bash configuration file for Web Application Developers (MAC OS X 10.10.4 (14E46))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## Web Application Development for BASH made easy | |
# This shell script contains a collection of excellent scripts I've found over the years that enhance development. | |
# It is organized much like a traditional etc/*conf file, and I hope others find it useful. | |
# | |
# YOU MUST HAVE X-CODE installed | |
# | |
# Features include: | |
# - Homebrew | |
# - Sexy git bash status prompt | |
# - NodeJS Version Manager (nvm) | |
# - Ruby Version Manager (rvm) | |
##### Configuration | |
# Allows NodeJS to open a lot of files concurrently, fixes issues with certain node modules like grunt | |
ulimit -n 10000 | |
##### Homebrew - Unix tools & open source software | |
# package manager for Mac OS X | |
# http://coolestguidesontheplanet.com/installing-homebrew-os-x-yosemite-10-10-package-manager-unix-apps/ | |
# Homebrew Path Variables | |
export PATH=/opt/local/bin:/opt/local/sbin:$PATH | |
export PATH=/usr/local/bin:$PATH | |
##### NodeJS | |
# http://www.nodejs.org | |
# | |
# This script uses the NodeJS Version Manager | |
# https://github.com/creationix/nvm | |
# Sets the default NodeJS-RunTime environment variable (NODE_ENV) | |
#SET Node_ENV=production | |
export NODE_ENV=development | |
# creates alias for nvm command to point to nvm.sh | |
export PATH="$PATH:$HOME/.nvm/bin" | |
[ -s "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh" # This loads nvm | |
# | |
# GIT BASH STATUS: | |
# | |
# Custom Personalised bash prompt # | |
# get current branch in git repo | |
function parse_git_branch() { | |
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ ! "${BRANCH}" == "" ] | |
then | |
STAT=`parse_git_dirty` | |
echo " (${BRANCH}${STAT})" | |
else | |
echo "" | |
fi | |
} | |
# | |
# get current status of git repo | |
# | |
function parse_git_dirty { | |
status=`git status 2>&1 | tee` | |
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` | |
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` | |
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"` | |
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"` | |
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"` | |
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"` | |
bits='' | |
if [ "${renamed}" == "0" ]; then | |
bits=">${bits}" | |
fi | |
if [ "${ahead}" == "0" ]; then | |
bits="*${bits}" | |
fi | |
if [ "${newfile}" == "0" ]; then | |
bits="+${bits}" | |
fi | |
if [ "${untracked}" == "0" ]; then | |
bits="?${bits}" | |
fi | |
if [ "${deleted}" == "0" ]; then | |
bits="x${bits}" | |
fi | |
if [ "${dirty}" == "0" ]; then | |
bits="!${bits}" | |
fi | |
if [ ! "${bits}" == "" ]; then | |
echo " ${bits}" | |
else | |
echo "" | |
fi | |
} | |
# | |
# | |
# Custom Prompt, user@host:~ (master) $ | |
# | |
# | |
export PS1="\[$(tput setaf 2)\]\u@\h\[$(tput setaf 7)\]:\[$(tput setaf 8)\]\w\[$(tput setaf 7)\]\[$(tput sgr0)\]\`parse_git_branch\` $ " | |
# Super User Prompt | |
export SUDO_PS1="\[\e[33;1;41m\][\u] \w \$\[\e[0m\] " | |
nvm use 0.12 | |
echo 'enter nvm use <version> to change' | |
brew -v | |
##### Ruby Version Manager | |
# https://rvm.io/ | |
# Add RVM to PATH for scripting | |
# Set alias to execute rvm command | |
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
rvm use 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment