I just figured this out today.

#!/bin/bash
echo $(dirname $PWD/$0)