Skip to content

Instantly share code, notes, and snippets.

@Tukki
Created June 30, 2015 04:50
Show Gist options
  • Save Tukki/e6a79f9bf93ad7530348 to your computer and use it in GitHub Desktop.
Save Tukki/e6a79f9bf93ad7530348 to your computer and use it in GitHub Desktop.
shell判断脚本的当前目录. bash/zsh
if [ -n "$BASH" ] ; then
_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
_basepath=$(dirname "$_DIR")
fi
if [ -n "$ZSH_VERSION" ]; then
_DIR="$(dirname $(cd -P -- "$(dirname -- "$0")" && pwd -P))"
_basepath=$_DIR
fi
echo $_basepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment