Back to Terminal Gui

Terminal.Gui Key Binding Config Examples

Examples/Config/README.md

2.0.13.4 KB
Original Source

Terminal.Gui Key Binding Config Examples

This folder contains example config.json files that override Terminal.Gui's default key bindings to match platform conventions.

How to Use

Copy the desired file to ~/.tui/config.json (the global Terminal.Gui config location).

OSWant macOS feel?Want Windows feel?
WindowsCopy macos.json~/.tui/config.json(already default)
macOS(already default)Copy windows.json~/.tui/config.json

On Windows ~ expands to C:\Users\<username>.
On macOS/Linux ~ expands to /home/<username> (or /Users/<username> on macOS).

What Each File Changes

macos.json — macOS-style bindings (for Windows users)

Overrides Terminal.Gui's default key bindings to match macOS conventions:

What changesDefault (Windows)With macos.json
Quit appEscEsc or Ctrl+Q
Suspend app to background(not available)Ctrl+Z
UndoCtrl+ZCtrl+Z or Ctrl+/
RedoCtrl+YCtrl+Y or Ctrl+Shift+Z
Delete char rightDeleteDelete or Ctrl+D

Note: Emacs navigation shortcuts (Ctrl+B/Ctrl+F for left/right in text fields, Ctrl+N/Ctrl+P for up/down in text views and lists) are already available on all platforms — no override needed.

windows.json — Windows-style bindings (for macOS users)

Overrides Terminal.Gui's default key bindings to match Windows conventions:

What changesDefault (macOS)With windows.json
Quit appEsc or Ctrl+QEsc only
Suspend app to backgroundCtrl+Z(disabled)
UndoCtrl+Z or Ctrl+/Ctrl+Z only
RedoCtrl+Y or Ctrl+Shift+ZCtrl+Y only
Delete char rightDelete or Ctrl+DDelete only

Limitation: Emacs navigation shortcuts built into text views (Ctrl+B, Ctrl+F, Ctrl+N, Ctrl+P, Ctrl+K, etc.) are set in C# code and cannot be removed via config.json. They remain available alongside the standard keys.

How It Works

Terminal.Gui's ConfigurationManager loads ~/.tui/config.json and uses it to replace the values of three key binding properties:

  • Application.DefaultKeyBindings — app-level commands (Quit, Suspend, Tab navigation)
  • View.DefaultKeyBindings — shared commands across all views (navigation, clipboard, editing)
  • View.ViewKeyBindings — per-view overrides (keyed by view type name, e.g. "TextField")

The JSON format maps command names to PlatformKeyBinding objects:

json
{
    "Application.DefaultKeyBindings": {
        "Quit": { "All": ["Esc", "Ctrl+Q"] }
    },
    "View.DefaultKeyBindings": {
        "Undo": { "All": ["Ctrl+Z"], "Linux": ["Ctrl+/"], "Macos": ["Ctrl+/"] }
    },
    "View.ViewKeyBindings": {
        "TextField": {
            "WordLeft": { "All": ["Ctrl+CursorLeft"] }
        }
    }
}

Each PlatformKeyBinding has four optional fields:

FieldApplies to
AllEvery platform
WindowsWindows only (added to All)
LinuxLinux only (added to All)
MacosmacOS only (added to All)

Important: When you override a property (e.g. View.DefaultKeyBindings), your JSON replaces the entire default dictionary. Any command you omit reverts to having no binding from that layer. Always include all commands you want active.