How to create a custom command to run currently opened prolog file using swipl

I have multiple prolog files in a directory and want to conveniently run them using builder ui. i made a program with hardcoded filename of prolog file: swipl ./lab2.prolog. I want to lab2.prolog be replaced with a filename of currently opened file, something like swipl $CURR_FILE

That’s a nice idea I hadn’t thought about before when using the shellcmd plugin. Once plugins/shellcmd: provide most recent page file path/uri (27b75a58) · Commits · GNOME / gnome-builder · GitLab is in Nightly you can set your command to something like this:

sh -c 'echo $CURRENT_FILE_PATH'

Unfortunately the sh -c is required to get the variable to expand.

I tried this:
swipl $(sh -c echo $CURRENT_FILE_PATH)
But I’m getting this error from prolog interpreter:

ERROR: Prolog initialisation failed:
ERROR: file `'$(sh'' does not exist

I also tried your command:
sh -c 'echo $CURRENT_FILE_PATH'
And this one outputs newline in app output terminal

It might work better to do sh -c 'swipl "$CURRENT_FILE_PATH"'.

Is it possible your most recently focused page wasn’t an editor page? It looks at the most recently focused page to get the current GFile.

Thanks, this one works. Interesting that Use Subshell checkbutton doesn’t have the same effect.

I set this command as Run Command and clicked play button, while focused on editor page.
Now I tried setting keyboard shortcut and using this shortcut. It works fine, though opens a new TerminalPage

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.