Created
August 28, 2015 14:58
-
-
Save asaaki/9af7bc2451d3dcb03c8d to your computer and use it in GitHub Desktop.
Absolute final directory path of origin script
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
#!/bin/sh | |
# Shamelessly stolen from: | |
# https://github.com/michaeldfallen/git-radar/blob/master/git-radar#L7-L13 | |
if [[ "$OSTYPE" == *darwin* ]]; then | |
READLINK_CMD='greadlink' | |
else | |
READLINK_CMD='readlink' | |
fi | |
script_location="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; pwd)" | |
echo "I was called from: $0" | |
echo "Final directory of the origin script is at: $script_location" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment