Skip to content

Instantly share code, notes, and snippets.

@mattmc3 mattmc3/
Last active Jul 27, 2019

What would you like to do?
Bash: get current script directory (zsh too)
# source this file
__main() {
local this_script="${BASH_SOURCE[0]:-${(%):-%x}}"
local this_dir="$(cd $(dirname "$this_script") && pwd)"
echo $this_script
echo $this_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.