Skip to content

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].

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
FieldTypeDescription
namestringLabel shown in the user-command output view.
commandsarray of stringsProgram + arguments. First element is the binary, rest are args.
typeinline (default) / silent / suspendHow the command runs, see below.
refreshbool (default false)After execution, refresh the commit list. Incompatible with inline (validated at config-load).
tab_widthint (sibling of commands_N)Display width for \t characters in command output. Applies to all commands.
  • inline, output renders inside a gitoui pane. gitoui stays alive, you can scroll the output. Best for git 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).

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.

Inside the commands array, these tokens are substituted at runtime with values from the focused commit / view:

TokenValue
{{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.

[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"]
  • 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.
  • inline blocks the UI until the command exits. Prefer suspend for interactive tools, or background with & + silent.