Last Updated: February 25, 2016
· destructuring

Getting the root of your project

It's useful to get the root of your project, so you can fully qualify paths to scripts, config files and not worry about the current directory.

In bash, I define shome to be (assuming the script is in a subdirectory). I got this from a script in ronn.

shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"

In ruby: