So, I'm tweaking my dotfiles to automatically install packages and I want to automatically detect whether the installation script is being ran in a Gitpod workspace. This is what I have at the moment:
if is-executable "gp"; then
echo "Gitpod detected, not installing <pre-installed package>"
else
# Continue with installation... rest of code goes here
fi
I know that gp
is a command available in Gitpod due to it's CLI and the code above works fine, but it isn't really ideal, assuming that other packages also have the gp
command outside of Gitpod (although I don't use them). So, what would be a better way to detect if a Bash script is being ran in Gitpod?
You can use this function from the snippet here:
function is::gitpod() {
# Check for existence of this gitpod-specific file and the ENV var.
test -e /ide/bin/gitpod-code && test -v GITPOD_REPO_ROOT;
}
Also, if you're interested, check out dotsh, it's already doing what you're trying to do here and even more!