Skip to content

Instantly share code, notes, and snippets.

@csells
Last active February 23, 2026 03:04
Show Gist options
  • Select an option

  • Save csells/3740f3ebc4754b8bfee7a441cd8f5f03 to your computer and use it in GitHub Desktop.

Select an option

Save csells/3740f3ebc4754b8bfee7a441cd8f5f03 to your computer and use it in GitHub Desktop.
Create an Action Button in VSCode to start a session of the pi coding agent in a new terminal window in the editor area

๐Ÿš€ Auto-Setup: "Run Pi" VS Code Macro Button & Shortcut

This prompt is designed for AI coding agents (like Cursor, GitHub Copilot Chat, or an autonomous CLI agent).

By feeding this prompt to your AI assistant, it will automatically configure VS Code to add a custom macro that:

  1. Opens a new terminal natively within the Editor Area (rather than the bottom panel).
  2. Instantly executes the pi CLI command.

To make this easily accessible, the agent will map the macro to both a keyboard shortcut (Ctrl+Alt+P) and a clickable UI button on your VS Code Status Bar.


๐Ÿ“‹ The Agent Prompt

Copy and paste everything below this line into your AI Agent:

Act as an expert VS Code configuration assistant. I need you to completely automate the setup of a custom VS Code macro. Please execute the following steps automatically without asking for manual intervention:

Step 1: Install the Required Extension Run the following command in my terminal to install the Action Buttons extension, which is required to draw custom UI elements on the status bar: code --install-extension seunlanlege.action-buttons

Step 2: Locate Global Config Files Determine my operating system and locate my global VS Code keybindings.json and settings.json files.

  • Windows: %APPDATA%\Code\User\
  • Mac: $HOME/Library/Application Support/Code/User/
  • Linux: $HOME/.config/Code/User/

Step 3: Update keybindings.json Read my existing keybindings.json. If it's empty, initialize it as an array []. Append the following JSON object to the array to configure the native macro:

{
    "key": "ctrl+alt+p", 
    "command": "runCommands",
    "args": {
        "commands": [
            "workbench.action.createTerminalEditor",
            {
                "command": "workbench.action.terminal.sendSequence",
                "args": {
                    "text": "pi\u000D"
                }
            }
        ]
    }
}

**Step 4: Update settings.json** Read my global settings.json. Merge the following actionButtons configuration into the root object to create the UI button. If the actionButtons key already exists, simply append this new button object to its existing commands array.

"actionButtons": {
    "reloadButton": null,
    "loadNpmCommands": false,
    "commands": [
        {
            "name": "$(terminal) Run Pi",
            "color": "#42b983",
            "tooltip": "Open Terminal in Editor Area and run pi",
            "useVsCodeApi": true,
            "command": "runCommands",
            "args": [
                {
                    "commands": [
                        "workbench.action.createTerminalEditor",
                        {
                            "command": "workbench.action.terminal.sendSequence",
                            "args": {
                                "text": "pi\u000D"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

Step 5: Finalize Confirm when the files have been successfully written and remind me to run the Refresh Action Buttons command via the Command Palette (or reload my VS Code window) to make the status bar button appear.


โš ๏ธ Known Caveat: The Race Condition

Because VS Code's runCommands executes sequentially, there is a small chance on slower machines that the macro will attempt to type the pi command before the new terminal has fully initialized. If you click the button and the terminal opens but the command doesn't run, simply click the button or hit the hotkey one more time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment