pi-bash-code-actions
A Pi extension that detects fenced bash, sh, shell, and zsh blocks in assistant replies and shows an informational note in the transcript. Use /bash-blocks to choose an action:
- Copy the block to the system clipboard (
wl-copy,xclip, orxselon Linux;pbcopyon macOS;clipon Windows). - Open terminal with the block loaded as a temporary script. It prefers Konsole, then
$TERMINAL, GNOME Terminal, andx-terminal-emulator. - Execute after showing the code in a Pi confirmation dialog. Execution takes place in the newly opened terminal.
The transcript note is informational; it is not clickable. 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.