Skip to content

Instantly share code, notes, and snippets.

@mathsigit
Last active June 1, 2017 03:23
Show Gist options
  • Save mathsigit/8f1a651d8423c24629e59d2b460ab47d to your computer and use it in GitHub Desktop.
Save mathsigit/8f1a651d8423c24629e59d2b460ab47d to your computer and use it in GitHub Desktop.
My ~/.bash_profile on mac
function docker_container_ip() {
  container_ids=$(docker ps -aq)
  for cid in ${container_ids}
  do
    info=$(docker inspect -f 'name={{.Name}}  ip={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${cid})
    echo -e "$cid \t $info"
  done
}
##Set JDK version and JAVA_HOME
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
setjdk 1.8
##Set Scala after install svm
##How to install svm:http://scala.masanorihashimoto.com/2014/04/how-to-install-the-scala-version-manager-on-your-mac/
export SCALA_HOME=~/.svm/current/rt
export PATH=$SCALA_HOME/bin:$PATH
# chrmoe-canary
#chrome \
# --headless \ # Runs Chrome in headless mode.
# --disable-gpu \ # Temporarily needed for now.
# --remote-debugging-port=9222 \
# https://www.chromestatus.com # URL to open. Defaults to about:blank.
#To see:https://developers.google.com/web/updates/2017/04/headless-chrome
alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
# List all docker container name and ip address
function docker_container_ip() {
container_ids=$(docker ps -aq)
for cid in ${container_ids}
do
cname=$(docker ps -af "id=${cid}" --format "{{.Names}}")
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${cid})
echo -e "$cid \t $cname \t $ip"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment