
Source: turnoff.us
Cookbook
Find the directory of the running script
__DIR__=$(cd "$(dirname "$0")" && pwd)
dirname "$0" gives the script’s directory and cd ... && pwd turns it into an absolute path.
Quote the inner command substitution: without the quotes, a path containing spaces is split into
several arguments and cd fails with “too many arguments”. The && makes the script stop instead
of falling back to a wrong directory if the cd fails.
Date aliases
alias isodate='date +%Y-%m-%dT%H:%M:%S%z'
Prints the current time in ISO 8601 with the timezone offset, for example
2026-06-15T08:14:27+0200.