Skip to content
Cogno v0.5.0

Keybindings

A keybinding connects a key combination to an action. Each one is a keybind line in your config file:

keybind = Ctrl+M=minimize_window

Left of the second = is the key, right of it the action. Changes apply as soon as you save the file.

The examples on this page use Ctrl. On macOS you will usually want Command instead.

Find the action’s name in All actions and write a line for it:

keybind = Ctrl+Alt+D=split_right

Your lines are added to the defaults, so you only list what you change. Two rules decide what happens on a conflict:

  • One key per action. The last line that names an action sets its key. The line above moves split_right to Ctrl+Alt+D; its default key stops working.
  • One action per key. If two actions end up on the same key, the later line wins.

There is no way to remove a binding without replacing it. To free a key, bind its action to a different key.

A combination is any number of modifiers and one key, joined with +. It must not contain spaces.

Modifiers — case and order do not matter:

ModifierAlso written as
CtrlControl
Shift
AltOption, Opt
CommandCmd, Meta, Super, Win

Keys — these are case-sensitive:

KeysWritten as
Lettersuppercase: A … Z
Digits0 … 9
Function keysF1, F2, …
ArrowsLeft, Right, Up, Down
NavigationHome, End, PageUp, PageDown, Insert, Delete
Other named keysEnter, Escape, Tab, Space, Backspace
Punctuationthe character itself: , . / ; ' [ ] - ` \

The characters =, > and : are part of the syntax and cannot be used as keys.

Chain combinations with > to require several key presses in a row:

keybind = Ctrl+B>Ctrl+S=open_config

Press Ctrl+B, release, then Ctrl+S.

Some actions take an argument after a :. new_tab takes the name of a shell profile:

keybind = Ctrl+Alt+B=new_tab:bash

An argument runs to the end of the line and may contain any character, including spaces, : and =.

The same action with different arguments can have several keys. new_tab:bash and new_tab:zsh each get their own, next to the key of plain new_tab.

A trigger in front of the key changes when the binding fires and whether the terminal still receives the key. Without a trigger, the action runs and the key is not passed on to the terminal.

keybind = always:performable:Ctrl+C=copy
TriggerEffect
alwaysThe binding also works while a full-screen program such as vim or htop is running. Without it, the key goes to that program instead.
performableThe key is only taken if the action actually did something. Otherwise it goes to the terminal. This is how Ctrl+C copies when text is selected and interrupts the command when nothing is.
unconsumedThe action runs and the key is passed on to the terminal.
broadcastThe action runs in every terminal of the window, in all workspaces, not only the focused one — for example to clear the input line in all panes at once.
workspaceThe action runs in every terminal of the workspace you are looking at.

Triggers can be combined, each followed by a :.

send_text types its argument into the terminal for you. It has no default key:

keybind = Ctrl+Alt+T=send_text:npm test\r

The \r at the end presses Enter. Without it the text is only typed and waits for you.

The text goes to whatever is running in the terminal — your shell at the prompt, or a program that is waiting for input.

Write these escapes for keys that have no character of their own:

EscapeSends
\rEnter
\eEscape
\tTab
\nLine feed
\xHHThe character with hex code HH, from 00 to 7F
\\A backslash

Ctrl with a letter is a \xHH code: Ctrl+A is \x01, Ctrl+B is \x02, and so on up to Ctrl+Z, which is \x1a. So \x03 is Ctrl+C and \x04 is Ctrl+D.

Any other backslash is sent as written. Spaces at the end of the line are dropped; write \x20 for a space the text has to end with.

terminate_processes ends the program that is running in a terminal, together with everything that program started. The shell stays open at its prompt. It has no default key.

Use it where Ctrl+C is not enough: the program is first asked to end and, if it is still running after two seconds, killed. This also works for programs that ignore Ctrl+C and for full-screen programs such as vim.

Programs you sent to the background with & keep running. On Windows this distinction does not exist: everything started from the terminal is ended, immediately.

With the workspace or broadcast trigger an action runs in many terminals at once. Together with the two actions above, one key ends everything that is running:

# End every running program in the current workspace
keybind = always:workspace:Ctrl+Alt+K=terminate_processes
# End every running program in all workspaces
keybind = always:broadcast:Ctrl+Alt+Shift+K=terminate_processes
# Press Ctrl+C in every terminal of the current workspace
keybind = always:workspace:Ctrl+Alt+C=send_text:\x03

The always trigger keeps the key working while the terminal you are in runs a full-screen program.

# Give an action without a default key one
keybind = Ctrl+Alt+I=open_process_info
# Keep a shortcut working inside vim, htop and other full-screen programs
keybind = always:Ctrl+Shift+P=open_command_palette
# Clear the screen of every terminal at once
keybind = broadcast:Ctrl+Alt+L=clear_buffer
# A two-step sequence
keybind = Ctrl+B>Ctrl+W=close_all_tabs

If a line names an action that does not exist, Cogno shows a warning and ignores the line.