Last active
September 28, 2015 14:52
-
-
Save igilham/b699a01fc5fc0e380b4f to your computer and use it in GitHub Desktop.
profile
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
| #!/bin/bash | |
| # Profile for Mac OS X systems | |
| # Proxy setup ---------------------------------------------------------- | |
| export PROXY_HOST=www-proxy.example.com | |
| export PROXY_PORT=80 | |
| function proxy_reset() { | |
| if [ "$1" = "MyCompany On Network" ]; then | |
| export http_proxy=http://${PROXY_HOST}:${PROXY_PORT} | |
| export https_proxy=${http_proxy} | |
| export HTTP_PROXY=${http_proxy} | |
| export HTTPS_PROXY=${https_proxy} | |
| export PLATFORM_JAVA_OPTS="${BASE_JAVA_OPTS} \ | |
| -Dhttp.proxyHost=${PROXY_HOST} \ | |
| -Dhttp.proxyPort=${PROXY_PORT} \ | |
| -Dhttps.proxyHost=${PROXY_HOST} \ | |
| -Dhttps.proxyPort=${PROXY_PORT} \ | |
| -Dhttp.nonProxyHosts='localhost|localhost.localdomain' \ | |
| " | |
| if command -v git >/dev/null 2>&1; then | |
| git config --global http.proxy "${PROXY_HOST}:${PROXY_PORT}" | |
| git config --global https.proxy "${PROXY_HOST}:${PROXY_PORT}" | |
| fi | |
| if command -v npm >/dev/null 2>&1; then | |
| npm config set proxy "http://${PROXY_HOST}:${PROXY_PORT}" | |
| npm config set https-proxy "http://${PROXY_HOST}:${PROXY_PORT}" | |
| fi | |
| else | |
| export http_proxy= | |
| export https_proxy= | |
| export HTTP_PROXY= | |
| export HTTPS_PROXY= | |
| export PLATFORM_JAVA_OPTS="${BASE_JAVA_OPTS}" | |
| if command -v git >/dev/null 2>&1; then | |
| git config --global --remove-section http | |
| git config --global --remove-section https | |
| fi | |
| if command -v npm >/dev/null 2>&1; then | |
| npm config delete proxy | |
| npm config delete https-proxy | |
| fi | |
| fi | |
| export no_proxy='localhost,127.0.0.1,localhost.localdomain' | |
| export MAVEN_OPTS="-Xms256m -Xmx512m $PLATFORM_JAVA_OPTS" | |
| } | |
| # Get the current network location from Mac OS X's Location setting from | |
| # Network Preferences then reset env vars as required | |
| function proxy() { | |
| case "$1" in | |
| "on") sudo networksetup -switchtolocation "MyCompany On Network" >/dev/null;; | |
| "off") sudo networksetup -switchtolocation "MyCompany Off Network" >/dev/null;; | |
| esac | |
| NETWORK_LOCATION="$(networksetup -getcurrentlocation)" | |
| echo "Network location: ${NETWORK_LOCATION}" | |
| proxy_reset "${NETWORK_LOCATION}" | |
| } | |
| # Aliases ---------------------------------------------------------- | |
| alias ls='ls -FGh' | |
| alias ll='ls -l' | |
| alias la='ls -la' | |
| alias diff='colordiff' | |
| alias webserve='python -m SimpleHTTPServer 8000' | |
| alias brup='brew update && brew upgrade --all && brew cleanup' | |
| command -v thefuck > /dev/null 2>&1 && eval "$(thefuck --alias)" | |
| # ENV vars ---------------------------------------------------------- | |
| export EDITOR=vim | |
| PATH=/usr/local/sbin:/usr/local/bin:${PATH} | |
| PATH=$(brew --prefix coreutils)/libexec/gnubin:${PATH} | |
| PATH=$(brew --prefix gnu-sed)/libexec/gnubin:${PATH} | |
| export JAVA_HOME=/Library/Java/Home | |
| export M2_HOME="$(brew --prefix maven)/libexec" | |
| export M2="${M2_HOME}/bin" | |
| export GRADLE_HOME="$(brew --prefix gradle)/libexec" | |
| export PYTHONPATH=/usr/local/lib/python2.7/site-packages:${PYTHONPATH} | |
| # golang root | |
| export GOROOT="$(brew --prefix go)/libexec" | |
| # mono GAC root | |
| export MONO_GAC_PREFIX="/usr/local" | |
| # rbenv ruby environment thingy | |
| export RBENV_ROOT=/usr/local/var/rbenv | |
| if if command -v rbenv >/dev/null 2>&1; then; then eval "$(rbenv init -)"; fi | |
| eval "$(rbenv init -)" | |
| # Haskell Platform | |
| if [ -d "${PATH}:/Users/gilhai01/Library/Haskell/bin" ]; then | |
| PATH="${PATH}:/Users/gilhai01/Library/Haskell/bin" | |
| fi | |
| # Android SDK | |
| if [ -d "${HOME}/Library/Android/sdk/platform-tools" ] ; then | |
| PATH="${HOME}/Library/Android/sdk/platform-tools:$PATH" | |
| fi | |
| export PATH | |
| export MANPATH=$(brew --prefix coreutils)/libexec/gnuman:${MANPATH} | |
| export DOCKER_HOST=127.0.0.1:4243 | |
| CERT_DIR="${HOME}/.cert" | |
| CERT_FILE="cert-YYYY-mm-DD.p12" | |
| CERT_PASS="changeme" | |
| # java certificates stuff | |
| export BASE_JAVA_OPTS="\ | |
| -Djavax.net.ssl.trustStore=${CERT_DIR}/jssecacerts \ | |
| -Djavax.net.ssl.keyStore=${CERT_DIR}/${CERT_FILE} \ | |
| -Djavax.net.ssl.keyStorePassword=${CERT_PASS} \ | |
| -Djavax.net.ssl.keyStoreType=PKCS12 \ | |
| " | |
| # Bash prompt ---------------------------------------------------------- | |
| # default bash prompt | |
| export PS1='\[\e]0;\w\a\]\[\e[34m\]\u@\h: \[\e[35m\]\w\[\e[0m\] \[$?\]\n\$ ' | |
| # multi-line continuation prompt | |
| export PS2='> ' # Secondary prompt | |
| export PS3='#? ' # Prompt 3 | |
| export PS4='+' # Prompt 4 | |
| export CLICOLOR=1 | |
| # History ---------------------------------------------------------- | |
| export HISTCONTROL=ignoredups | |
| #export HISTCONTROL=erasedups | |
| export HISTFILESIZE=3000 | |
| export HISTIGNORE="ls:cd:[bf]g:exit:..:...:ll:lla" | |
| proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment