Get the path of commands using "realpath" and "which"
Sometimes you need to load resources that are relative to some tool. On POSIX (with a compatible shell), you can use:
realpath $(which command)
This finds the absolute path (including resolving links) to the command named command
which is on PATH
.
And if you need to run a command in the directory of a tool:
pushd $(dirname $(realpath $(which command)))
command ...
popd