Skip to content

Instantly share code, notes, and snippets.

@adduc
Created October 16, 2018 15:52
Show Gist options
  • Save adduc/e7a8d2c6fe3b8b8a6c5d459d8a69ce18 to your computer and use it in GitHub Desktop.
Save adduc/e7a8d2c6fe3b8b8a6c5d459d8a69ce18 to your computer and use it in GitHub Desktop.
#!/bin/bash
SOURCED=0
CD=0
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
SOURCED=1
fi
if [[ $1 =~ ^(cd|apps|notes|trunk|repos|docker)?$ ]]; then
CD=1
fi
if [ $SOURCED -eq 1 ] && [ $CD -eq 0 ]; then
$BASH_SOURCE "$@"
return
fi
if [ $CD -eq 0 ]; then
set -ex
fi
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
case "$1" in
apps)
cd "${ROOT}/apps"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment