Last active
January 24, 2017 21:00
-
-
Save jongrover/9958933 to your computer and use it in GitHub Desktop.
Bash Profile
This file contains 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
# Configuring Our Prompt | |
# ====================== | |
# Reset | |
# Color_Off='\e[0m' # Text Reset | |
# Regular Colors | |
# Black='\e[0;30m' # Black | |
# Red='\e[0;31m' # Red | |
# Green='\e[0;32m' # Green | |
# Yellow='\e[0;33m' # Yellow | |
# Blue='\e[0;34m' # Blue | |
# Purple='\e[0;35m' # Purple | |
# Cyan='\e[0;36m' # Cyan | |
# White='\e[0;37m' # White | |
# # Bold | |
# BBlack='\e[1;30m' # Black | |
# BRed='\e[1;31m' # Red | |
# BGreen='\e[1;32m' # Green | |
# BYellow='\e[1;33m' # Yellow | |
# BBlue='\e[1;34m' # Blue | |
# BPurple='\e[1;35m' # Purple | |
# BCyan='\e[1;36m' # Cyan | |
# BWhite='\e[1;37m' # White | |
# # Underline | |
# UBlack='\e[4;30m' # Black | |
# URed='\e[4;31m' # Red | |
# UGreen='\e[4;32m' # Green | |
# UYellow='\e[4;33m' # Yellow | |
# UBlue='\e[4;34m' # Blue | |
# UPurple='\e[4;35m' # Purple | |
# UCyan='\e[4;36m' # Cyan | |
# UWhite='\e[4;37m' # White | |
# # Background | |
# On_Black='\e[40m' # Black | |
# On_Red='\e[41m' # Red | |
# On_Green='\e[42m' # Green | |
# On_Yellow='\e[43m' # Yellow | |
# On_Blue='\e[44m' # Blue | |
# On_Purple='\e[45m' # Purple | |
# On_Cyan='\e[46m' # Cyan | |
# On_White='\e[47m' # White | |
# # High Intensity | |
# IBlack='\e[0;90m' # Black | |
# IRed='\e[0;91m' # Red | |
# IGreen='\e[0;92m' # Green | |
# IYellow='\e[0;93m' # Yellow | |
# IBlue='\e[0;94m' # Blue | |
# IPurple='\e[0;95m' # Purple | |
# ICyan='\e[0;96m' # Cyan | |
# IWhite='\e[0;97m' # White | |
# # Bold High Intensity | |
# BIBlack='\e[1;90m' # Black | |
# BIRed='\e[1;91m' # Red | |
# BIGreen='\e[1;92m' # Green | |
# BIYellow='\e[1;93m' # Yellow | |
# BIBlue='\e[1;94m' # Blue | |
# BIPurple='\e[1;95m' # Purple | |
# BICyan='\e[1;96m' # Cyan | |
# BIWhite='\e[1;97m' # White | |
# # High Intensity backgrounds | |
# On_IBlack='\e[0;100m' # Black | |
# On_IRed='\e[0;101m' # Red | |
# On_IGreen='\e[0;102m' # Green | |
# On_IYellow='\e[0;103m' # Yellow | |
# On_IBlue='\e[0;104m' # Blue | |
# On_IPurple='\e[0;105m' # Purple | |
# On_ICyan='\e[0;106m' # Cyan | |
# On_IWhite='\e[0;107m' # White | |
# \a an ASCII bell character (07) | |
# \d the date in "Weekday Month Date" format (e.g., "Tue May 26") | |
# \D{format} the format is passed to strftime(3) and the result | |
# is inserted into the prompt string an empty format | |
# results in a locale-specific time representation. | |
# The braces are required | |
# \e an ASCII escape character (033) | |
# \h the hostname up to the first `.' | |
# \H the hostname | |
# \j the number of jobs currently managed by the shell | |
# \l the basename of the shell's terminal device name | |
# \n newline | |
# \r carriage return | |
# \s the name of the shell, the basename of $0 (the portion following | |
# the final slash) | |
# \t the current time in 24-hour HH:MM:SS format | |
# \T the current time in 12-hour HH:MM:SS format | |
# \@ the current time in 12-hour am/pm format | |
# \A the current time in 24-hour HH:MM format | |
# \u the username of the current user | |
# \v the version of bash (e.g., 2.00) | |
# \V the release of bash, version + patch level (e.g., 2.00.0) | |
# \w the current working directory, with $HOME abbreviated with a tilde | |
# \W the basename of the current working directory, with $HOME | |
# abbreviated with a tilde | |
# \! the history number of this command | |
# \# the command number of this command | |
# \$ if the effective UID is 0, a #, otherwise a $ | |
# \nnn the character corresponding to the octal number nnn | |
# \\ a backslash | |
# \[ begin a sequence of non-printing characters, which could be used | |
# to embed a terminal control sequence into the prompt | |
# \] end a sequence of non-printing characters | |
# This function is called in your prompt to output your active git branch. | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# This function builds your prompt. It is called below | |
function prompt { | |
# Define some local colors | |
local BLACK='\e[0;30m' # Black | |
local RED='\e[0;31m' # Red | |
local GREEN='\e[0;32m' # Green | |
local YELLOW='\e[0;33m' # Yellow | |
local BLUE='\e[0;34m' # Blue | |
local PURPLE='\e[0;35m' # Purple | |
local CYAN='\e[0;36m' # Cyan | |
local WHITE='\e[0;37m' # White | |
local OFF='\e[0m' # Reset | |
#local LIGHT_RED="\[\033[1;31m\]" | |
local CHAR="♥" | |
# ♥ ☆ ▶ ☠ ☹ ☁ ☂ Keeping some cool ASCII Characters for reference | |
# export PS1="\[\e]2;\u@\h\a\[\e[37;44;1m\]\t\[\e[0m\]$RED\$(parse_git_branch) \[\e[32m\]\W\[\e[0m\]\n\[\e[0;31m\]$CHAR \[\e[0m\]" | |
export PS1="\[\e]2;\u@\h\a\[$BLACK\]\t\[$OFF\] $BLUE\W\[$CYAN\]\$(parse_git_branch)\[$OFF\]\n\[$PURPLE\]$CHAR \[$OFF\]" | |
PS2='> ' | |
PS4='> ' | |
} | |
# Finally call the function and our prompt is all pretty | |
prompt | |
# For more prompt coolness, check out Halloween Bash: | |
# http://xta.github.io/HalloweenBash/ | |
# If you break your prompt, just delete the last thing you did. | |
# And that's why it's good to keep your dotfiles in git too. | |
# Environment Variables | |
# ===================== | |
# Library Paths | |
#RVM PATH | |
export RVM_PATH="$HOME/.rvm/bin" | |
# NODE_PATHS | |
export NODE_MODULES_PATH="/usr/local/share/npm/lib/node_modules" | |
export NPM_PATH="/usr/local/share/npm/bin" | |
# PYTHON_SHARE | |
export PYTHON_SHARE='/usr/local/share/python' | |
#PHP PATH | |
export PHP_PATH="/usr/local/Cellar/php/5.3.10/bin" | |
### Heroku Toolbelt | |
export HEROKU_PATH="/usr/local/heroku/bin" | |
### RabbitMQ | |
export RABBIT_PATH="/usr/local/sbin" | |
export USR_PATHS="/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin" | |
export NEW_GIT_PATH="/usr/local/git/bin" | |
export POSTGRES_APP_PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin" | |
export PATH="$POSTGRES_APP_PATH:$NEW_GIT_PATH:$USR_PATHS:$RVM_PATH:$PYTHON_SHARE:$PHP_PATH:$HEROKU_PATH:$NODE_MODULES_PATH:$NPM_PATH:$RABBIT_PATH:$PATH" | |
# If you go into your shell and type: $PATH you will see the output of your current path. | |
# Configurations | |
# GIT_MERGE_AUTO_EDIT | |
# This variable configures git to not require a message when you merge. | |
export GIT_MERGE_AUTOEDIT='no' | |
# Editors | |
# Tells your shell that when a program requires various editors, use sublime. | |
# The -w flag tells your shell to wait until sublime exits | |
export VISUAL="subl -w" | |
export SVN_EDITOR="subl -w" | |
export GIT_EDITOR="subl -w" | |
export EDITOR="subl -w" | |
# Version | |
# What version of the Flatiron School bash profile this is | |
export FLATIRON_VERSION='1.1.1' | |
# Helpful Functions | |
# ===================== | |
# A function to create new github repos from the command line | |
# USE: gh repo-name | |
function gh () { | |
curl -s -u 'jongrover:c7a1c5b3a992a4a4ef7d2165718b02cffe1a1408' https://api.github.com/user/repos -d "{\"name\":\"$1\"}" | sed -n '/"ssh_url"/p' | gawk 'match($0, /:{1}\s"(.*)"/, ary) {print ary[1]}' | pbcopy | |
} | |
# A function to create new github repos for a specific organization (defaults to private repos) | |
# USE: gho repo-name org-name | |
function gho () { | |
if [ -n "$3" ]; then | |
private=$("false") | |
else | |
private=$("true") | |
fi | |
curl -s -u 'jongrover:c7a1c5b3a992a4a4ef7d2165718b02cffe1a1408' https://api.github.com/orgs/"$2"/repos -d "{\"name\":\"$1\",\"private\":\"$private\"}" | sed -n '/"ssh_url"/p' | gawk 'match($0, /:{1}\s"(.*)"/, ary) {print ary[1]}' | pbcopy | |
} | |
#Angular 2 Install Project | |
function tsa { | |
tsd install angular2 es6-promise rx rx-lite | |
} | |
# Angular 2 TypeScript Watch file shortcut with preset options | |
function tsw { | |
tsc --watch -m commonjs -t es5 --emitDecoratorMetadata --experimentalDecorators $@ | |
} | |
# Functions to navigate the file system | |
function desktop { | |
cd /Users/$USER/Desktop/$@ | |
} | |
function documents { | |
cd /Users/$USER/Documents/$@ | |
} | |
function downloads { | |
cd /Users/$USER/Downloads/$@ | |
} | |
function web { | |
cd /Users/$USER/web-dev/$@ | |
} | |
function max { | |
cd /Users/$USER/max/$@ | |
} | |
function proccessing { | |
cd /Users/$USER/processing/$@ | |
} | |
# A function to easily grep for a matching process | |
# USE: psg postgres | |
function psg { | |
FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'` | |
REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'` | |
ps aux | grep "[$FIRST]$REST" | |
} | |
# A function to extract correctly any archive based on extension | |
# USE: extract imazip.zip | |
# extract imatar.tar | |
function extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; | |
*.tgz) tar xzf $1 ;; | |
*.zip) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*) echo "'$1' cannot be extracted via extract()" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
# Aliases | |
# ===================== | |
# LS | |
alias l='ls -lah' | |
# Git | |
alias gst="git status" | |
alias gl="git pull" | |
alias gp="git push" | |
alias gd="git diff | mate" | |
alias gc="git commit -v" | |
alias gca="git commit -v -a" | |
alias gb="git branch" | |
alias gba="git branch -a" | |
# Python | |
alias pyserver="python -m SimpleHTTPServer" | |
#cacheless node server | |
alias nodeserver="http-server -c-1" | |
#live-reload node server | |
alias liveserver="live-server" | |
# Case-Insensitive Auto Completion | |
bind "set completion-ignore-case on" | |
# Postgres | |
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH | |
# Final Configurations and Plugins | |
# ===================== | |
# Git Bash Completion | |
# Will activate bash git completion if installed | |
# via homebrew | |
if [ -f `brew --prefix`/etc/bash_completion ]; then | |
. `brew --prefix`/etc/bash_completion | |
fi | |
# RVM | |
# Mandatory loading of RVM into the shell | |
# This must be the last line of your bash_profile always | |
[[ -s "/Users/$USER/.rvm/scripts/rvm" ]] && source "/Users/$USER/.rvm/scripts/rvm" # This loads RVM into a shell session. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment