shellnushell

Get current script location in Nu shell


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.


Solution

  • 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.