repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/nu-bang/README.md

Raw

nu-bang

Nushell bang-command bridge for Pi.

Runs Pi ! and !! shell input through Nushell. Adds Nushell completions for bang input. Requires nu in PATH.

Install / load

Loaded through the root pi-ext package. See root README.

Commands / tools / settings

Behavior

Markdown source
File outline
# nu-bang

Nushell bang-command bridge for Pi.

Runs Pi `!` and `!!` shell input through Nushell.
Adds Nushell completions for bang input.
Requires `nu` in `PATH`.

## Install / load

Loaded through the root pi-ext package.
See [root README](../../README.md).

## Commands / tools / settings

- Commands:
  none
- Tools:
  none
- Hooks:
  `user_bash`, `session_start`, `session_shutdown`
- Settings:
  none

## Behavior

- `user_bash` replaces Pi shell operations with Nushell execution for the
  Pi-provided command.
- Commands run as `nu --no-history --error-style fancy --table-mode none -c
  <command>`.
- Execution receives Pi cwd, env, abort signal, and timeout.
- Working directory is checked before execution and completion.
- Abort and timeout terminate the spawned Nushell process.
- Output has terminal control sequences removed before it is returned.
- Long output is truncated with Pi's output truncation helper.
- Truncated full output is written to `pi-nu-bang-output-*.log` temp files with
  mode `0600`.
- `session_start` wraps the current autocomplete provider.
- Bang completion strips leading `!` or `!!` before asking Nushell for
  completions.
- Bang completion uses `nu --no-history --error-style fancy -I <cwd>
  --ide-complete <offset> <temp>/command.nu`.
- Completion temp files live in `pi-nu-bang-*` temp dirs and are removed after
  use.
- Non-bang completion delegates to the existing provider.
- Bang completion failures fall back to the existing provider unless the request
  was aborted.
- Completion prefix detection handles pipes, spaces, cell paths, quoted paths,
  and escaped-space paths.
- Completion application replaces the current Nushell token and removes a stale
  closing quote when needed.
- Bang input always allows file-completion triggering; non-bang input delegates
  that decision.
- Completion JSON accepts Nushell's normal output and salvages malformed quoted
  list items.
- `session_shutdown` removes temporary completion dirs still tracked by the
  extension.