Skip to main content
One-shot mode lets you use Opsh without entering the interactive REPL. Pass your request as a quoted argument and Opsh generates, displays, and — after your confirmation — runs the command, then exits. This makes Opsh easy to use inline, in scripts, or from keyboard shortcuts.

Basic usage

Pass your request as a quoted argument to opsh:
Opsh generates the appropriate command, shows it with a risk level and explanation, and asks for confirmation before running it.

Examples

Exit codes

Flags

Preview the generated command without running it. Opsh displays the command and explanation, then exits without executing anything:
This is useful when you want to check what Opsh would generate before committing to it, or when you’re building automation and want to audit commands first.

--shell

Override shell detection for the session. Opsh normally detects your current shell automatically, but you can force it to generate commands for a specific shell:
Accepted values are zsh and bash.

Using one-shot mode in scripts and automation

One-shot mode is well-suited for automation workflows because it exits cleanly after each command. You can capture the exit code to handle success and failure:
You can also combine it with --print-only to preview commands in a CI or review workflow without executing anything.
When Opsh is not running in a TTY (for example, in a script or pipeline), it skips the interactive confirmation prompt and proceeds directly with the default action. Review your confirmByDefault setting in your configuration before using one-shot mode in automated contexts.