Run Shell Commands Imperatively
While useShell() runs a command on a fixed interval, runShell() executes it once when called. Use it for button clicks, event-driven actions, or when you need to post-process output before rendering.
Declare the command
As with useShell, declare the command in fluxlay.yaml.
fluxlay.yaml
Run on button click
Post-process output before rendering
When to use which
Notes
- Returns
Promise<ShellResult>with{ stdout, stderr, statusCode, success, signal }. Checksuccess(orstatusCode === 0) before usingstdout. - The command ID must be declared in the
shellsection offluxlay.yaml. Unknown IDs throw an error. - Pass
columns/linesto control the pseudo-terminal size (useful for tools that adapt to terminal width).
See the runShell Reference for full API details.