realpath $0
I guess for a symlink, we can do:
readlink $0
One liner to go to the directory where the file lives:
cd "$(dirname "$(realpath "$0")")"
TODO: write about a solution that works for both files and symlinks