Current directory of aliased script in bash

To get a current directory of a script when ran trough alias:

$(dirname $(realpath "${BASH_SOURCE[0]}"))

where:

  • BASH_SOURCE[0] contains path of the script
  • realpath prints resolved path (source of the alias)
  • dirname returns directory portion of the path