How can I add a currently focused file/tab to a task argument?

Currently I’m playing around with using Nova to edit Pico-8 (.p8) files - which are essentially Lua files. My current Run task (shell script) looks something like this:

$PICO8_APP/pico8 ./file.p8

Which works if I’m just editing on game, but if I have a folder full of games that I’m working on I’d like to be able to simply run the one I’m currently working on without having to go and edit the task every time.

I tried adding *FilePath as an ‘Argument(s) Passed on Launch’ but it doesn’t seem to have an effect.

How can I configure a task to pass the currently focused tab/file/folder/etc to a task script?

Any help greatly appreciated.

Bryan

Hello Bryan,

I believe you are on the right track. If you add an argument for File Path to the shell arguments, it will then be available in different ways depending on what scripting language you’re using for your script.

If it’s pure shell script / bash / zsh, it will be available as $1. Or, if you’re using Python for example, it will be available from sys.argv[1].

In that way, for the above, I think you should be able to do what you want by adding the argument and switching your task to $PICO8_APP/pico8 $1.

If you aren’t seeing this working, let me know and I’m happy to help investigate further.

Ah @logan thank you - your suggestion works perfectly.

1 Like

One last little question. Is it possible to do any ‘string munging’ with the args?
For instance if I want to create binaries with Pico-8 I use the --export {filename}.bin flag. I just need the file name, and not the extension.

Also, is there anyway to have arguments only passed to specific tasks? If I pass the --export… flag with the ‘Run’ task it somewhat defeats the purpose, as I only want that to be present in the Build task.

Update: Never mind, I just did any munging required in the shell.

Also, is there anyway to have arguments only passed to specific tasks? If I pass the --export… flag with the ‘Run’ task it somewhat defeats the purpose, as I only want that to be present in the Build task.

Not at the moment. In this case, it might be better to pass the arguments as Environment Variables in the table below the Arguments say as one named FILE_PATH or something, and then reference them with $FILE_PATH instead of $1, that way you could pass any arguments to the task and only reference those you wanted.