Skip to content

Instantly share code, notes, and snippets.

@sgen
Last active August 21, 2018 17:01
Show Gist options
  • Save sgen/578cd938eb5a49a6b420938d36630587 to your computer and use it in GitHub Desktop.
Save sgen/578cd938eb5a49a6b420938d36630587 to your computer and use it in GitHub Desktop.
Find the project root from a script
#!/bin/bash
# $(cd $(dirname "$0"); pwd -P) finds the scripts path;
#
# /../ Is the path of the script relative to the project root
#
# realpath normalizes the path
export project_root=$(realpath $(cd $(dirname "$0"); pwd -P)/../);
echo "$project_root";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment