In bash, we can retrieve the current script's path by $0
variable, so if any script has a dependency resource which is under the same directory as the script directory, we can use it even when we're not executing the script in the script's directory.
How can I retrieve the current script's path in fish shell?
status --current-filename
is what you're looking for.
Note that this handles both sourced and executed files, while $0 in bash is only for executed files.