Get current script location in Nu shell

1k Views Asked by At

In bash you can use $0 variable to get the location of the current script. How I do the same in Nu? echo $nu doesn't seem to have anything I can use.

3

There are 3 best solutions below

3
dols3m On BEST ANSWER

As long as you know the name of the file, you can do:

$env.FILE_PWD | path join filename

This will only work if you are executing the file as a script, not sourcing it.

0
Darren On

I don't think there's a way to do this yet. I was playing with history | last but it's one off, as you'd expect.

1
jiahut On

($nu.config-path | path dirname )