User commands
Custom shell commands wired to a keybind, for project-specific actions
(run a test suite, open the current commit in tig / lazygit, ping a
deploy script, …). The command and the key are configured separately:
the command lives under [core.user_command], the key under [keybind].
Define commands
Section titled “Define commands”Each command is an entry commands_N (where N is the command’s ID):
[core.user_command]commands_1 = { name = "Run tests", commands = ["cargo", "test", "--workspace"] }commands_2 = { name = "Open in tig", type = "suspend", commands = ["tig", "{{target_hash}}"] }commands_3 = { name = "Notify deploy", type = "silent", commands = ["notify-send", "deploy started"] }tab_width = 4| Field | Type | Description |
|---|---|---|
name | string | Label shown in the user-command output view. |
commands | array of strings | Program + arguments. First element is the binary, rest are args. |
type | inline (default) / silent / suspend | How the command runs, see below. |
refresh | bool (default false) | After execution, refresh the commit list. Incompatible with inline (validated at config-load). |
tab_width | int (sibling of commands_N) | Display width for \t characters in command output. Applies to all commands. |
Execution types
Section titled “Execution types”inline, output renders inside a gitoui pane. gitoui stays alive, you can scroll the output. Best forgit diff,git log, static-output inspection.silent, output discarded. Best for fire-and-forget commands (notify-send, background&, …).suspend, gitoui drops alt-screen + raw mode, the command takes over the terminal, gitoui resumes on exit. Best for interactive editors (vim,nano) and full-screen TUIs (tig,lazygit).
Bind a key
Section titled “Bind a key”The command entry itself does not carry a key. To bind a shortcut,
use [keybind] with the special user_command_N action name where N
matches the command’s ID:
[keybind]user_command_1 = ["f5"]user_command_2 = ["f6"]user_command_3 = ["ctrl-d"]When you press the bound key, gitoui dispatches UserCommand(N) →
opens the user-command view → runs commands_N.
Placeholders
Section titled “Placeholders”Inside the commands array, these tokens are substituted at runtime
with values from the focused commit / view:
| Token | Value |
|---|---|
{{target_hash}} | Full SHA of the focused commit. |
{{first_parent_hash}} | Full SHA of the focused commit’s first parent. |
{{parent_hashes}} | All parent SHAs, space-separated (useful for merges). |
{{refs}} | All refs pointing at the commit (branches + remote branches + tags). |
{{branches}} | Local branch names at the commit. |
{{remote_branches}} | Remote branch names at the commit. |
{{tags}} | Tag names at the commit. |
{{area_width}} | Width (cells) of the user-command output pane. |
{{area_height}} | Height (cells) of the output pane. |
{{area_width}} / {{area_height}} are handy for tools that take a
--width / --columns flag, pass the pane size so output wraps
correctly inside gitoui rather than against your terminal width.
Full worked example
Section titled “Full worked example”[core.user_command]commands_1 = { name = "git diff (colored)", type = "inline", commands = [ "git", "--no-pager", "diff", "--color=always", "{{first_parent_hash}}", "{{target_hash}}",] }commands_2 = { name = "Open in tig", type = "suspend", commands = ["tig", "{{target_hash}}"] }commands_3 = { name = "Run tests", commands = ["cargo", "test", "--workspace"], refresh = true }
[keybind]user_command_1 = ["f5"]user_command_2 = ["f6"]user_command_3 = ["f7"]Limits
Section titled “Limits”- Commands run with the same env as the gitoui process, no isolation, no sandbox.
- Output renders verbatim; ANSI escape codes (colors, cursor moves) pass through.
inlineblocks the UI until the command exits. Prefersuspendfor interactive tools, or background with&+silent.