Created
July 9, 2017 21:42
-
-
Save jlr7245/94d34b51e992e575699b7bfbf1a41429 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
# A list of all directories in which to look for commands, | |
# scripts and programs | |
# PATH="$HOME/.rbenv/bin:$PATH" # RBENV | |
PATH="/usr/local/share/npm/bin:$PATH" # NPM | |
PATH="/usr/local/bin:/usr/local/sbin:$PATH" # Homebrew | |
PATH="/usr/local/heroku/bin:$PATH" # Heroku Toolbelt | |
# Uncomment to use GNU versions of core utils by default. | |
# See scripts/mac/homebrew_install_core_utils.sh in the Installfest. | |
# In essence, Mac OS X is in BSD userland, while Linux et al are in | |
# GNU. GNU utils tend towards current POSIX compliance and are more | |
# feature-rich; thus they are aliased below to add color, clean output | |
# etc. BSD tools are more stable. Mac has also added some Mac-specific | |
# abilities to its set of BSD-like coreutils, however: check | |
# `man chmod`, eg. | |
# PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" # Coreutils | |
# MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" # Manual pages | |
# ================= | |
# Settings | |
# ================= | |
# Prefer US English | |
export LC_ALL="en_US.UTF-8" | |
# use UTF-8 | |
export LANG="en_US" | |
# ================= | |
# History | |
# ================= | |
# http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/ | |
# Larger bash history (allow 32³ entries; default is 500) | |
export HISTSIZE=32768 | |
export HISTFILESIZE=$HISTSIZE | |
# don't put duplicate lines in the history. | |
export HISTCONTROL=ignoredups | |
# ignore same sucessive entries. | |
export HISTCONTROL=ignoreboth | |
# Make some commands not show up in history | |
export HISTIGNORE="h" | |
# ==================== | |
# Aliases | |
# ==================== | |
## 'ls' lists information about files. | |
# By default, show slashes for directories. | |
alias ls='gls -F' | |
# Enhanced ls, grouping directories and using colors. | |
alias lf='gls --color -h --group-directories-first -F' | |
# Long list format including hidden files and file information. | |
alias ll='gls --color -h --group-directories-first -Fla' | |
# List ACLs (finer-grained permissions that can be inherited). | |
# ACLs are a necessary part of OSX fs since 10.6; see | |
# - ACLs on OSX: https://goo.gl/PhkcA2 | |
# - OSX chmod manpage: https://goo.gl/vJqgZ9 | |
# | |
# Note: The default ls on 10.7+ OSX is the GNU coreutils version at: | |
# /usr/local/opt/coreutils/libexec/gnubin/ls; in order to see the | |
# ACL permissions, we must use the BSD version available at: /bin/ls | |
alias lacl='/bin/ls -GFlae' | |
# Go back one directory | |
alias b='cd ..' | |
# History lists your previously entered commands | |
alias h='history' | |
# If we make a change to our bash profile we need to reload it | |
alias reload="clear; source ~/.bash_profile" | |
# Execute verbosely | |
alias cp='gcp -v' | |
alias mv='gmv -v' | |
alias rm='grm -v' | |
alias mkdir='gmkdir -pv' | |
alias trm='touch README.md' | |
alias j-staticb='touch index.html && mkdir styles src && cd styles && touch style.css reset.css && cd ../src && touch main.js && cd .. && code .' | |
alias j-expressb='touch README.md app.js .gitignore && mkdir views routes controllers models && code .' | |
alias 'brewski'='brew update && brew upgrade && brew cleanup; brew doctor' | |
# ================= | |
# Change System Settings | |
# ================= | |
# Hide/show all desktop icons (useful when presenting) | |
alias hide_desktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder" | |
alias show_desktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder" | |
# Hide/show hidden files in Finder | |
alias hide_files="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder" | |
alias show_files="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder" | |
# ================ | |
# Application Aliases | |
# ================ | |
# Sublime should be symlinked. Otherwise use one of these | |
alias subl='open -a "Sublime Text"' | |
# alias subl='open -a "Sublime Text 2"' | |
alias chrome='open -a "Google Chrome"' | |
# ================= | |
# nvm (load io.js as node) | |
# ================= | |
export NVM_DIR=~/.nvm | |
source ~/.nvm/nvm.sh | |
# nvm use stable > /dev/null # PJ: using .nvmrc to set this... uncomment if not working | |
# ================= | |
# Functions | |
# ================= | |
####################################### | |
# Quick Jump To Today's WDI Folder | |
# See the script for usage. | |
####################################### | |
if [ -f ~/.bash_wdi_command.sh ]; then | |
source ~/.bash_wdi_command.sh | |
fi | |
####################################### | |
# Set ACL permissions to inherit and | |
# allow read, write and update actions. | |
# | |
# Arguments: | |
# 1. Group Name | |
# 2. Directory Path | |
####################################### | |
allow_group() { | |
local GROUP_NAME="$1" | |
local TARGET_DIR="$2" | |
local PERMISSIONS="read,write,delete,add_file,add_subdirectory" | |
local INHERITANCE="file_inherit,directory_inherit" | |
sudo mkdir -p "$TARGET_DIR" | |
sudo /bin/chmod -R -N "$TARGET_DIR" | |
sudo /bin/chmod -R +a "group:$GROUP_NAME:allow $PERMISSIONS,$INHERITANCE" "$TARGET_DIR" | |
} | |
####################################### | |
# Start an HTTP server from a directory | |
# Arguments: | |
# Port (optional) | |
####################################### | |
server() { | |
local port="${1:-8000}" | |
(sleep 2 && open "http://localhost:${port}/")& | |
# Simple Pythong Server: | |
# python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" | |
# Simple Ruby Webrick Server: | |
ruby -e "require 'webrick';server = WEBrick::HTTPServer.new(:Port=>${port},:DocumentRoot=>Dir::pwd );trap('INT'){ server.shutdown };server.start" | |
} | |
####################################### | |
# List any open internet sockets on | |
# several popular ports. Useful if a | |
# rogue server is running. | |
# - http://www.akadia.com/services/lsof_intro.html | |
# - http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers | |
# | |
# No Arguments. | |
####################################### | |
rogue() { | |
# add or remove ports to check here! | |
local PORTS="3000 4567 6379 8000 8888 27017" | |
local MESSAGE="> Checking for processes on ports" | |
local COMMAND="lsof" | |
for PORT in $PORTS; do | |
MESSAGE="${MESSAGE} ${PORT}," | |
COMMAND="${COMMAND} -i TCP:${PORT}" | |
done | |
echo "${MESSAGE%?}..." | |
local OUTPUT="$(${COMMAND})" | |
if [ -z "$OUTPUT" ]; then | |
echo "> Nothing running!" | |
else | |
echo "> Processes found:" | |
printf "\n$OUTPUT\n\n" | |
echo "> Use the 'kill' command with the 'PID' of any process you want to quit." | |
echo | |
fi | |
} | |
google() { | |
chrome "https://www.google.com/search?q=$*" | |
} | |
mdn() { | |
google "$*+site:developer.mozilla.org&btnI=1s" | |
} | |
ghe() { | |
chrome "https://git.generalassemb.ly" | |
} | |
ghe_c() { | |
CUR_DIR="$(pwd)" | |
chrome "https://git.generalassemb.ly/wdi-nyc-delorean/${CUR_DIR##/*/}" | |
} | |
gh() { | |
chrome "https://github.com" | |
} | |
gh_c() { | |
CUR_DIR="$(pwd)" | |
chrome "https://github.com/jlr7245/${CUR_DIR##/*/}" | |
} | |
w3s() { | |
google "$*+site:https://www.w3schools.com&btnI=1s" | |
} | |
w3c() { | |
google "$*+site:https://www.w3schools.com&btnI=1s" | |
} | |
ruby-doc() { | |
google "$*+site:ruby-doc.org&btnI=1" | |
} | |
lecture() { | |
wdi-search "lecture_u0$1_d0$2" | |
} | |
lab() { | |
wdi-search "lab_u0$1_d0$2" | |
} | |
hw() { | |
wdi-search "hw_u0$1_d0$2" | |
} | |
morning() { | |
wdi-search "morning_u0$1_d0$2" | |
} | |
wdi-search() { | |
chrome "https://git.generalassemb.ly/wdi-nyc-delorean?q=$*" | |
} | |
motivation() { | |
MESSAGE="you can do it, $(whoami)!" | |
echo $MESSAGE | |
say $MESSAGE | |
} | |
# ================= | |
# Sourced Scripts | |
# ================= | |
# Builds the prompt with git branch notifications. | |
if [ -f ~/.bash_prompt.sh ]; then | |
source ~/.bash_prompt.sh | |
fi | |
# A welcome prompt with stats for sanity checks | |
if [ -f ~/.welcome_prompt.sh ]; then | |
source ~/.welcome_prompt.sh | |
fi | |
# bash/zsh completion support for core Git. | |
if [ -f ~/.git-completion.bash ]; then | |
source ~/.git-completion.bash | |
fi | |
# ==================================== | |
# Environmental Variables and API Keys | |
# ==================================== | |
# Below here is an area for other commands added by outside programs or | |
# commands. Attempt to reserve this area for their use! | |
########################################################################## | |
export HOMEBREW_EDITOR=nano | |
export NODE_REPL_HISTORY_FILE=~/.node_repl_history | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
# Setting PATH for Python 3.6 | |
# The original version is saved in .bash_profile.pysave | |
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" | |
export PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment