← Catalog

@vahor/pi-keymap

Vim-like custom keymaps for binding keyboard shortcuts to shell commands in pi.

Extension

Install

Install with PiG

pig install npm:@vahor/pi-keymap

Install with Pi

pi install npm:@vahor/pi-keymap
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./dist/index.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.0.13 (README.md). PiG does not review it.

@vahor/pi-keymap

npm downloads

Define Vim-like custom keymaps that bind keyboard shortcuts to shell commands.

pi install npm:@vahor/pi-keymap

Config

Configuration is loaded from both locations and merged recursively. keymaps arrays are merged by key, so project entries replace global entries with the same key:

LocationScope
~/.pi/agent/keymap.jsonGlobal keymaps
.pi/keymap.jsonProject keymaps; overrides global values

If neither file exists, the extension creates .pi/keymap.json with an empty config and a $schema field for editor validation.

// .pi/keymap.json
{
  "leader": "space",
  "keymaps": [
    // Direct shortcuts
    {
      "key": "ctrl+shift+t",
      "commands": ["bun run test"]
    },
    // Leader-prefixed shortcuts (triggered via leader key + sub-key)
    {
      "key": "<leader>f",
      "description": "Format",
      "commands": [{ "command": "bun run format", "timeout": 1000, "print": true }]
    },
    {
      "key": "<leader>p",
      "description": "Draft prompt in pi editor",
      "prompt": "Default prompt content",
      "send": false,
      "open": true
    },
    {
      "key": "<leader>g",
      "description": "Git",
    },
    // Nested leader keys
    {
      "key": "<leader>gg",
      "commands": [{ "command": "lazygit", "interactive": true }]
    },
  ]
}
FieldTypeRequiredDescription
leaderstringYesKey that activates the which-key overlay
keymapsarrayYesList of keymap entries
keymaps[].keystringYesKey combination or <leader>key
keymaps[].descriptionstringNoLabel shown in the which-key overlay (falls back to first command)
keymaps[].commandsarrayNoShell commands to run. Required for command keymaps.
keymaps[].promptstringNoDefault prompt text.
keymaps[].sendbooleanNoFor prompt keymaps, send saved content immediately instead of placing it in the input editor. Defaults false
keymaps[].openbooleanNoFor prompt keymaps, open editor before using the prompt. Defaults true; false uses the prompt immediately according to send.
keymaps[].printbooleanNoPrint command output in the UI. Defaults true
keymaps[].contextbooleanNoAdd command output to the agent context
keymaps[].interactivebooleanNoDefault interactive mode for commands in this keymap

commands, prompt, and grouping entries are mutually exclusive shapes: use commands for shell commands, prompt for prompt drafts, or neither for a leader grouping node. print, context, and interactive can be overridden at command level. Command-level wins over keymap-level.

Key format

modifier+key where modifiers are ctrl, shift, alt, super (e.g. ctrl+shift+p, alt+x).

Valid base keys:

CategoryKeys
Lettersa–z
Digits0–9
Namedescape, esc, enter, return, tab, space, backspace, delete, insert, clear, home, end, pageUp, pageDown
Arrowsup, down, left, right
Functionf1–f12
Symbols`, -, =, [, ], \, ;, ', ,, ., /, !, @, #, $, %, ^, &, *, (, ), _, +, |, ~, {, }, :, <, >, ?

Invalid keys are warned at startup and skipped.

Command format

Each entry can be a string (just the command) or an object:

FieldTypeRequiredDefaultDescription
commandstringYes–Shell command to run
cwdstringNoproject rootWorking directory (relative)
timeoutnumberNo30000Timeout in milliseconds
printbooleanNotrueRender command output in pi
contextbooleanNofalseAdd command output to the agent context
interactivebooleanNofalseSuspend pi's TUI and run with full terminal access. Use for commands like lazygit, vim, htop, or fzf. Output is not captured.

Command output is rendered in pi when print or context is enabled. Interactive commands restore and fully redraw pi after they exit.

Leader key & which-key overlay

Press the configured leader key to open a full-width bottom overlay listing all leader-prefixed keymaps. The overlay only opens when the input editor is empty, so typing a space (if your leader is space) won't accidentally trigger it. Press the sub-key to run the mapping, or escape to dismiss. The overlay auto-closes after 5 seconds.

Leader keys can be nested: <leader>g shows a sub-overlay with its children (gp → git push, gpf → git push --force). Prefix-only nodes (no commands, just a description) act as grouping folders.

Which-key entry styles:

Mapping stateStyle
Default commandAccent key
print: falseAccent key, appends dim (silent)
context: truePrefixed with #
interactive: truePrefixed with $
Prefix/group nodeWarning key + purple + label
LabelsPurple for groups, soft orange for actions