Skip to content

Get a scripts current path #4842

@FilipAndersson245

Description

@FilipAndersson245

Related problem

I want to write a script that uses relative paths to the script itself and not the called of the script, This enables the script to be run anywhere and not specifically in the script directory.

Describe the solution you'd like

I think it would be good to have some variable inside each script that enables you to access the path of the script.

dev/foo.nu
echo $CURRENT_SCRIPT_PATH

>> dev/foo.nu

Something like this, would be sufficient, Not to sure how this would work for multiple script files calling each other and vise versa?

Describe alternatives you've considered

Having an environment variable initialized once, and then using that inside the script instead, would be an alternative solution, but requires at least some configuration, but will work after done once.

Additional context and details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions