Repository navigation
[Feature]: Selected-file placeholder for terminal quick commands #18777
Description
Problem or use case
I want to replicate the VS Code "run arrow" workflow in Orca: select a file in the editor, click a saved quick command, and have that file run in the terminal. For example, run the currently open Python script with the project's virtualenv interpreter.
Today a terminal quick command cannot reference the active editor file. The saved command text is written to the terminal verbatim: sendTerminalQuickCommandToPane in src/renderer/src/components/terminal-pane/terminal-quick-command-dispatch.ts passes the text through flattenTerminalQuickCommand and buildTerminalQuickCommandInput in src/shared/terminal-quick-commands.ts, which only join lines with ; and append \r. No placeholder substitution exists.
So a command like .\.venv\Scripts\python.exe "${file}" reaches PowerShell unchanged, PowerShell expands the undefined $file variable to an empty string, and Python tries to run the working directory:
python.exe: can't find '__main__' module in 'C:\\Github\\FINPLICITY\\SmettersToolbox'
The only workaround is one quick command per script with the path hard-coded, which does not scale past a handful of files.
Proposed solution
Add a small set of placeholders that Orca substitutes into a terminal quick command before sending it to the terminal, resolved against the editor tab that is active when the command is clicked. VS Code's variable names would be familiar to most users:
${file}- absolute path of the active editor file${relativeFile}- path relative to the worktree root${fileBasename},${fileDirname}- convenience pieces${workspaceFolder}- the worktree root
Substitution would happen in sendTerminalQuickCommandToPane (or a helper it calls) before flattenTerminalQuickCommand. Substituted paths should be quoted, or the docs should say to quote them, so paths with spaces work in both PowerShell and POSIX shells.
If no editor file is active, the placeholder should resolve to an empty string and the command should not be sent, with a short toast explaining why, rather than running a broken command.
The Quick Command editor dialog could list the supported placeholders under "Advanced".
Alternatives or additional context
- A dedicated "Run active file" button in the editor toolbar would cover the common case, but a placeholder is more general because it works for linters, formatters, test runners, and any custom script, not only interpreters.
- A quick command with "Append Enter" off that types the interpreter and waits for the user to paste a path is the closest thing available today. It still requires the user to fetch the path by hand.
- Tested on Windows 11 with the PowerShell terminal, but the gap applies to every shell since no substitution happens anywhere in the quick-command path.
Activity