pi-bash-code-actions

A Pi extension that detects fenced bash, sh, shell, and zsh blocks in assistant replies and adds actions to the transcript:

  • Copy the block to the system clipboard (wl-copy, xclip, or xsel on Linux; pbcopy on macOS; clip on Windows).
  • Open terminal with the block loaded as a temporary script. It prefers Konsole, then $TERMINAL, GNOME Terminal, and x-terminal-emulator.
  • Execute after showing the code in a Pi confirmation dialog. Execution takes place in the newly opened terminal.

The /bash-blocks command lets you select a detected block and choose an action. Existing session history is scanned when the extension starts.

Safety

Shell code is powerful. Opening a terminal or executing a block can modify files, install software, access networks, or affect the system. The Execute action always asks for confirmation; inspect the complete command before approving it. The warning shown for some risky patterns is only advisory and is not a security sandbox. Opening a terminal does not execute without normal shell interpretation of the script.

The extension only provides UI/actions in interactive Pi sessions. It does not execute code automatically when a block is detected.

Install

pi install git:git.enne2.net/enne2/pi-bash-code-actions

Then run /reload or restart Pi. The command /bash-blocks is available in the session.

Requirements

  • Pi 0.87.1 or newer
  • A terminal emulator for terminal actions
  • A clipboard utility for Copy

Development

The extension entry point is index.ts. The local extension API supplies the Pi and TUI dependencies.

S
Description
Pi extension for interactive actions on shell code blocks
Readme
33 KiB
Languages
TypeScript 100%