Control kitty from scripts

kitty can be controlled from scripts or the shell prompt. You can open new windows, send arbitrary text input to any window, name windows and tabs, etc. Let’s walk through a few examples of controlling kitty.

Tutorial

Start by running kitty as:

kitty -o allow_remote_control=yes -o enabled_layouts=tall

In order for control to work, allow_remote_control must be enabled in kitty.conf. Here we turn it on explicitly at the command line.

Now, in the new kitty window, enter the command:

kitty @ launch --title Output --keep-focus cat

This will open a new window, running the cat program that will appear next to the current window.

Let’s send some text to this new window:

kitty @ send-text --match cmdline:cat Hello, World

This will make Hello, World show up in the window running the cat program. The kitty @ send-text --match option is very powerful, it allows selecting windows by their titles, the command line of the program running in the window, the working directory of the program running in the window, etc. See kitty @ send-text --help for details.

More usefully, you can pipe the output of a command running in one window to another window, for example:

ls | kitty @ send-text --match title:Output --stdin

This will show the output of ls in the output window instead of the current window. You can use this technique to, for example, show the output of running make in your editor in a different window. The possibilities are endless.

You can even have things you type show up in a different window. Run:

kitty @ send-text --match title:Output --stdin

And type some text, it will show up in the output window, instead of the current window. Type Ctrl+D when you are ready to stop.

Now, let’s open a new tab:

kitty @ launch --type=tab --tab-title "My Tab" --keep-focus bash

This will open a new tab running the bash shell with the title “My Tab”. We can change the title of the tab with:

kitty @ set-tab-title --match title:My  New Title

Let’s change the title of the current tab:

kitty @ set-tab-title Master Tab

Now lets switch to the newly opened tab:

kitty @ focus-tab --match title:New

Similarly, to focus the previously opened output window (which will also switch back to the old tab, automatically):

kitty @ focus-window --match title:Output

You can get a listing of available tabs and windows, by running:

kitty @ ls

This outputs a tree of data in JSON format. The top level of the tree is all operating system kitty windows. Each OS window has an id and a list of tabs. Each tab has its own id, a title and a list of windows. Each window has an id, title, current working directory, process id (PID) and command-line of the process running in the window. You can use this information with kitty @ focus-window --match to control individual windows.

As you can see, it is very easy to control kitty using the kitty @ messaging system. This tutorial touches only the surface of what is possible. See kitty @ --help for more details.

Note that in the example’s above, kitty @ messaging works only when run inside a kitty window, not anywhere. But, within a kitty window it even works over SSH. If you want to control kitty from programs/scripts not running inside a kitty window, you have to implement a couple of extra steps. First start kitty as:

kitty -o allow_remote_control=yes --listen-on unix:/tmp/mykitty

The kitty --listen-on option tells kitty to listen for control messages at the specified path. See kitty --help for details. Now you can control this instance of kitty using the kitty @ --to command line argument to kitty @. For example:

kitty @ --to unix:/tmp/mykitty ls

Note that if all you want to do is run a single kitty “daemon” and have subsequent kitty invocations appear as new top-level windows, you can use the simpler kitty --single-instance option, see kitty --help for that.

The builtin kitty shell

You can explore the kitty command language more easily using the builtin kitty shell. Run kitty @ with no arguments and you will be dropped into the kitty shell with completion for kitty command names and options.

You can even open the kitty shell inside a running kitty using a simple keyboard shortcut (ctrl+shift+escape by default).

Note

This has the added advantage that you don’t need to use allow_remote_control to make it work.

Allowing only some windows to control kitty

If you do not want to allow all programs running in kitty to control it, you can selectively enable remote control for only some kitty windows. Simply create a shortcut such as:

map ctrl+k launch --allow-remote-control some_program

Then programs running in windows created with that shortcut can use kitty @ to control kitty. Note that any program with the right level of permissions can still write to the pipes of any other program on the same computer and therefore can control kitty. It can, however, be useful to block programs running on other computers (for example, over ssh) or as other users.

Note

You dont need allow_remote_control to make this work as it is limited to only programs running in that specific window. Be careful with what programs you run in such windows, since they can effectively control kitty, as if you were running with allow_remote_control turned on.

Mapping key presses to remote control commands

If you wish to trigger a remote control command easily with just a keypress, you can map it in kitty.conf. For example:

map F1 remote_control set-spacing margin=30

Then pressing the F1 key will set the active window margins to 30. The syntax for what follows remote_control is exactly the same as the syntax for what follows kitty @ above.

Note

You do not need allow_remote_control to use these mappings, as they are not actual remote programs, but are simply a way to resuse the remote control infrastructure via keybings.

Broadcasting what you type to all kitty windows

As a simple illustration of the power of remote control, lets have what we type sent to all open kitty windows. To do that define the following mapping in kitty.conf:

map F1 launch --allow-remote-control kitty +kitten broadcast

Now press, F1 and start typing, what you type will be sent to all windows, live, as you type it.

The remote control protocol

If you wish to develop your own client to talk to kitty, you can use the protocol specification.

kitty @

kitty @ [options] command ...

Control kitty by sending it commands. Set the allow_remote_control option to yes in kitty.conf for this to work.

Options

--to <TO>

An address for the kitty instance to control. Corresponds to the address given to the kitty instance via the kitty --listen-on option. If not specified, messages are sent to the controlling terminal for this process, i.e. they will only work if this process is run within an existing kitty window.

kitty @ close-tab

kitty @ close-tab [options]

Close the specified tab(s)

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--self

If specified close the tab this command is run in, rather than the active tab.

kitty @ close-window

kitty @ close-window [options]

Close the specified window(s)

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--self

If specified close the window this command is run in, rather than the active window.

kitty @ create-marker

kitty @ create-marker [options] MARKER SPECIFICATION

Create a marker which can highlight text in the specified window. For example: create_marker text 1 ERROR. For full details see: https://sw.kovidgoyal.net/kitty/marks/

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--self

If specified apply marker to the window this command is run in, rather than the active window.

kitty @ detach-tab

kitty @ detach-tab [options]

Detach the specified tab and either move it into a new OS window or add it to the OS Window containing the tab specified by –target-tab

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--target-tab <TARGET_TAB>, -t <TARGET_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--self

If specified detach the tab this command is run in, rather than the active tab.

kitty @ detach-window

kitty @ detach-window [options]

Detach the specified window and either move it into a new tab, a new OS window or add it to the specified tab. Use the special value new for –target-tab to move to a new tab. If no target tab is specified the window is moved to a new OS window.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--target-tab <TARGET_TAB>, -t <TARGET_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--self

If specified detach the window this command is run in, rather than the active window.

kitty @ disable-ligatures

kitty @ disable-ligatures [options] STRATEGY

Control ligature rendering for the specified windows/tabs (defaults to active window). The STRATEGY can be one of: never, always, cursor

Options

--all, -a

By default, ligatures are only affected in the active window. This option will cause ligatures to be changed in all windows.

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--match-tab <MATCH_TAB>, -t <MATCH_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ env

kitty @ env env_var1=val env_var2=val ...

Change the environment variables seen by processing in newly launched windows. Similar to the env option in kitty.conf, but affects running kitty instances. Empty values cause the environment variable to be removed.

kitty @ focus-tab

kitty @ focus-tab [options]

The active window in the specified tab will be focused.

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--no-response

Don’t wait for a response indicating the success of the action. Note that using this option means that you will not be notified of failures. Default: false

kitty @ focus-window

kitty @ focus-window [options]

Focus the specified window, if no window is specified, focus the window this command is run inside.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--no-response

Don’t wait for a response from kitty. This means that even if no matching window is found, the command will exit with a success code. Default: false

kitty @ get-colors

kitty @ get-colors [options] ...

Get the terminal colors for the specified window (defaults to active window). Colors will be output to stdout in the same syntax as used for kitty.conf

Options

--configured, -c

Instead of outputting the colors for the specified window, output the currently configured colors.

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

kitty @ get-text

kitty @ get-text [options]

Get text from the specified window

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--extent <EXTENT>

What text to get. The default of screen means all text currently on the screen. all means all the screen+scrollback and selection means currently selected text. Default: screen Choices: all, screen, selection

--ansi

By default, only plain text is returned. If you specify this flag, the text will include the formatting escape codes for colors/bold/italic/etc. Note that when getting the current selection, the result is always plain text.

--add-cursor

Add ANSI escape codes specifying the cursor position and style to the end of the text.

--add-wrap-markers

Add carriage returns at every line wrap location (where long lines are wrapped at screen edges).

--self

If specified get text from the window this command is run in, rather than the active window.

kitty @ goto-layout

kitty @ goto-layout [options] LAYOUT_NAME

Set the window layout in the specified tab (or the active tab if not specified). You can use special match value all to set the layout in all tabs.

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ kitten

kitty @ kitten [options] kitten_name

Run a kitten over the specified window (active window by default). The kitten_name can be either the name of a builtin kitten or the path to a python file containing a custom kitten. If a relative path is used it is searched for in the kitty config directory. If the kitten is a no_ui kitten and its handle response method returns a string or boolean, this is printed out to stdout.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

kitty @ last-used-layout

kitty @ last-used-layout [options] ...

Switch to the last used window layout in the specified tab (or the active tab if not specified).

Options

--all, -a

Change the layout in all tabs.

--no-response

Don’t wait for a response from kitty. This means that even if no matching tab is found, the command will exit with a success code. Default: false

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ launch

 kitty @ launch [options] [CMD ...]

Prints out the id of the newly opened window. Any command line arguments are assumed to be the command line used to run in the new window, if none are provided, the default shell is run. For example: :italic:`kitty @ launch --title Email mutt`.

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--no-response

Do not print out the id of the newly created window.

--self

If specified the tab containing the window this command is run in is used instead of the active tab

--title <WINDOW_TITLE>, --window-title <WINDOW_TITLE>

The title to set for the new window. By default, title is controlled by the child process.

--tab-title <TAB_TITLE>

The title for the new tab if launching in a new tab. By default, the title of the active window in the tab is used as the tab title.

--type <TYPE>

Where to launch the child process, in a new kitty window in the current tab, a new tab, or a new OS window or an overlay over the current window. Note that if the current window already has an overlay, then it will open a new window. The value of background means the process will be run in the background. The values clipboard and primary are meant to work with kitty @ launch --stdin-source to copy data to the system clipboard or primary selection. Default: window Choices: background, clipboard, os-window, overlay, primary, tab, window

--keep-focus

Keep the focus on the currently active window instead of switching to the newly opened window.

--cwd <CWD>

The working directory for the newly launched child. Use the special value current to use the working directory of the currently active window.

--env <ENV>

Environment variables to set in the child process. Can be specified multiple times to set different environment variables. Syntax: name=value.

--copy-colors

Set the colors of the newly created window to be the same as the colors in the currently active window.

--copy-cmdline

Ignore any specified command line and instead use the command line from the currently active window.

--copy-env

Copy the environment variables from the currently active window into the newly launched child process. Note that most shells only set environment variables for child processes, so this will only copy the environment variables that the shell process itself has not the environment variables child processes inside the shell see. To copy that enviroment, use the kitty remote control feature with kitty @launch --copy-env.

--location <LOCATION>

Where to place the newly created window when it is added to a tab which already has existing windows in it. after and before place the new window before or after the active window. neighbor is a synonym for after. Also applies to creating a new tab, where the value of after will cause the new tab to be placed next to the current tab instead of at the end. The values of vsplit and hsplit are only used by the splits layout and control if the new window is placed in a vertical or horizontal split with the currently active window. The default is to place the window in a layout dependent manner, typically, after the currently active window. Default: default Choices: after, before, default, first, hsplit, last, neighbor, vsplit

--allow-remote-control

Programs running in this window can control kitty (if remote control is enabled). Note that any program with the right level of permissions can still write to the pipes of any other program on the same computer and therefore can control kitty. It can, however, be useful to block programs running on other computers (for example, over ssh) or as other users.

--stdin-source <STDIN_SOURCE>

Pass the screen contents as STDIN to the child process. @selection is the currently selected text. @screen is the contents of the currently active window. @screen_scrollback is the same as @screen, but includes the scrollback buffer as well. @alternate is the secondary screen of the current active window. For example if you run a full screen terminal application, the secondary screen will be the screen you return to when quitting the application. Default: none Choices: @alternate, @alternate_scrollback, @screen, @screen_scrollback, @selection, none

--stdin-add-formatting

When using kitty @ launch --stdin-source add formatting escape codes, without this only plain text will be sent.

--stdin-add-line-wrap-markers

When using kitty @ launch --stdin-source add a carriage return at every line wrap location (where long lines are wrapped at screen edges). This is useful if you want to pipe to program that wants to duplicate the screen layout of the screen.

--marker <MARKER>

Create a marker that highlights text in the newly created window. The syntax is the same as for the toggle_marker map action (see Mark text on screen).

--os-window-class <OS_WINDOW_CLASS>

Set the WM_CLASS property on X11 and the application id property on Wayland for the newly created OS Window when using kitty @ launch --type=os-window. Defaults to whatever is used by the parent kitty process, which in turn defaults to kitty.

--os-window-name <OS_WINDOW_NAME>

Set the WM_NAME property on X11 for the newly created OS Window when using kitty @ launch --type=os-window. Defaults to kitty @ launch --os-window-class.

--color <COLOR>

Change colors in the newly launched window. You can either specify a path to a .conf file with the same syntax as kitty.conf to read the colors from, or specify them individually, for example: --color background=white --color foreground=red

--watcher <WATCHER>, -w <WATCHER>

Path to a python file. Appropriately named functions in this file will be called for various events, such as when the window is resized, focused or closed. See the section on watchers in the launch command documentation The launch command. Relative paths are resolved relative to the kitty config directory.

kitty @ ls

kitty @ ls [options]

List all windows. The list is returned as JSON tree. The top-level is a list of operating system kitty windows. Each OS window has an id and a list of tabs. Each tab has its own id, a title and a list of windows. Each window has an id, title, current working directory, process id (PID), command-line and environment of the process running in the window. Additionally, when running the command inside a kitty window, that window can be identified by the is_self parameter.

You can use these criteria to select windows/tabs for the other commands.

Options

--all-env-vars

Show all environment variables in output not just differing ones.

kitty @ new-window

kitty @ new-window [options] [CMD ...]

Open a new window in the specified tab. If you use the kitty @ new-window --match option the first matching tab is used. Otherwise the currently active tab is used. Prints out the id of the newly opened window (unless --no-response is used). Any command line arguments are assumed to be the command line used to run in the new window, if none are provided, the default shell is run. For example: kitty @ new-window –title Email mutt

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--title <TITLE>

The title for the new window. By default it will use the title set by the program running in it.

--cwd <CWD>

The initial working directory for the new window. Defaults to whatever the working directory for the kitty process you are talking to is.

--keep-focus

Keep the current window focused instead of switching to the newly opened window

--window-type <WINDOW_TYPE>

What kind of window to open. A kitty window or a top-level OS window. Default: kitty Choices: kitty, os

--new-tab

Open a new tab

--tab-title <TAB_TITLE>

When using –new-tab set the title of the tab.

--no-response

Don’t wait for a response giving the id of the newly opened window. Note that using this option means that you will not be notified of failures and that the id of the new window will not be printed out. Default: false

kitty @ remove-marker

kitty @ remove-marker [options]

Remove the currently set marker, if any.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--self

If specified apply marker to the window this command is run in, rather than the active window.

kitty @ resize-os-window

kitty @ resize-os-window [options]

Resize the specified OS Window. Note that some window managers/environments do not allow applications to resize their windows, for example, tiling window managers.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--action <ACTION>

The action to perform. Default: resize Choices: resize, toggle-fullscreen, toggle-maximized

--unit <UNIT>

The unit in which to interpret specified sizes Default: cells Choices: cells, pixels

--width <WIDTH>

Change the width of the window. Zero leaves the width unchanged. Default: 0

--height <HEIGHT>

Change the height of the window. Zero leaves the height unchanged. Default: 0

--incremental

Treat the specified sizes as increments on the existing window size instead of absolute sizes.

--self

If specified resize the window this command is run in, rather than the active window.

--no-response

Don’t wait for a response indicating the success of the action. Note that using this option means that you will not be notified of failures. Default: false

kitty @ resize-window

kitty @ resize-window [options]

Resize the specified window in the current layout. Note that not all layouts can resize all windows in all directions.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--increment <INCREMENT>, -i <INCREMENT>

The number of cells to change the size by, can be negative to decrease the size. Default: 2

--axis <AXIS>, -a <AXIS>

The axis along which to resize. If horizontal, it will make the window wider or narrower by the specified increment. If vertical, it will make the window taller or shorter by the specified increment. The special value reset will reset the layout to its default configuration. Default: horizontal Choices: horizontal, reset, vertical

--self

If specified resize the window this command is run in, rather than the active window.

kitty @ scroll-window

kitty @ scroll-window [options] SCROLL_AMOUNT

Scroll the specified window, if no window is specified, scroll the window this command is run inside. SCROLL_AMOUNT can be either the keywords start or end or an argument of the form <number>[unit][+-]. For example, 30 will scroll down 30 lines and 2p- will scroll up 2 pages. 3u will unscroll by 3 lines, which means that 3 lines will move from the scrollback buffer onto the top of the screen.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

kitty @ send-text

kitty @ send-text [options] [TEXT TO SEND]

Send arbitrary text to specified windows. The text follows Python escaping rules. So you can use escapes like x1b to send control codes and u21fa to send unicode characters. If you use the kitty @ send-text --match option the text will be sent to all matched windows. By default, text is sent to only the currently active window.

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--match-tab <MATCH_TAB>, -t <MATCH_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

--all

Match all windows.

--stdin

Read the text to be sent from stdin. Note that in this case the text is sent as is, not interpreted for escapes. If stdin is a terminal, you can press Ctrl-D to end reading.

--from-file <FROM_FILE>

Path to a file whose contents you wish to send. Note that in this case the file contents are sent as is, not interpreted for escapes.

--exclude-active

Do not send text to the active window, even if it is one of the matched windows.

kitty @ set-background-image

kitty @ set-background-image [options] PATH_TO_PNG_IMAGE

Set the background image for the specified OS windows. You must specify the path to a PNG image that will be used as the background. If you specify the special value “none” then any existing image will be removed.

Options

--all, -a

By default, background image is only changed for the currently active OS window. This option will cause the image to be changed in all windows.

--configured, -c

Change the configured background image which is used for new OS windows.

--layout <LAYOUT>

How the image should be displayed. The value of configured will use the configured value. Choices: configured, mirror-tiled, scaled, tiled

--no-response

Don’t wait for a response from kitty. This means that even if setting the background image failed, the command will exit with a success code. Default: false

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

kitty @ set-background-opacity

kitty @ set-background-opacity [options] OPACITY

Set the background opacity for the specified windows. This will only work if you have turned on dynamic_background_opacity in kitty.conf. The background opacity affects all kitty windows in a single os_window. For example: kitty @ set-background-opacity 0.5

Options

--all, -a

By default, colors are only changed for the currently active window. This option will cause colors to be changed in all windows.

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--match-tab <MATCH_TAB>, -t <MATCH_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ set-colors

kitty @ set-colors [options] COLOR_OR_FILE ...

Set the terminal colors for the specified windows/tabs (defaults to active window). You can either specify the path to a conf file (in the same format as kitty.conf) to read the colors from or you can specify individual colors, for example: kitty @ set-colors foreground=red background=white

Options

--all, -a

By default, colors are only changed for the currently active window. This option will cause colors to be changed in all windows.

--configured, -c

Also change the configured colors (i.e. the colors kitty will use for new windows or after a reset).

--reset

Restore all colors to the values they had at kitty startup. Note that if you specify this option, any color arguments are ignored and –configured and –all are implied.

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--match-tab <MATCH_TAB>, -t <MATCH_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ set-font-size

kitty @ set-font-size [options] FONT_SIZE

Sets the font size to the specified size, in pts. Note that in kitty all sub-windows in the same OS window must have the same font size. A value of zero resets the font size to default. Prefixing the value with a + or - increments the font size by the specified amount.

Options

--all, -a

By default, the font size is only changed in the active OS window, this option will cause it to be changed in all OS windows. It also changes the font size for any newly created OS Windows in the future.

kitty @ set-spacing

kitty @ set-spacing [options] MARGIN_OR_PADDING ...

Set the padding and margins for the specified windows (defaults to active window). For example: margin=20 or padding-left=10 or margin-h=30. The shorthand form sets all values, the *-h and *-v variants set horizontal and vertical values. The special value “default” resets to using the default value. If you specify a tab rather than a window, all windows in that tab are affected.

Options

--all, -a

By default, settings are only changed for the currently active window. This option will cause colors to be changed in all windows.

--configured, -c

Also change the configured padding and margins (i.e. the settings kitty will use for new windows).

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

--match-tab <MATCH_TAB>, -t <MATCH_TAB>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ set-tab-title

kitty @ set-tab-title [options] TITLE ...

Set the title for the specified tab(s). If you use the kitty @ set-tab-title --match option the title will be set for all matched tabs. By default, only the tab in which the command is run is affected. If you do not specify a title, the title of the currently active window in the tab is used.

Options

--match <MATCH>, -m <MATCH>

The tab to match. Match specifications are of the form: field:regexp. Where field can be one of: id, index, title, window_id, window_title, pid, cwd, env, cmdline and recent. You can use the ls command to get a list of tabs. Note that for numeric fields such as id, recent, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match the tab that contains the window with the specified id or title. The index number is used to match the nth tab in the currently active OS window. The recent number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.

kitty @ set-window-title

kitty @ set-window-title [options] [TITLE ...]

Set the title for the specified window(s). If you use the kitty @ set-window-title --match option the title will be set for all matched windows. By default, only the window in which the command is run is affected. If you do not specify a title, the last title set by the child process running in the window will be used.

Options

--temporary

By default, if you use set-window-title the title will be permanently changed and programs running in the window will not be able to change it again. If you want to allow other programs to change it afterwards, use this option.

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2

kitty @ signal-child

kitty @ signal-child [options] [SIGNAL_NAME ...]

Send one or more signals to the foreground process in the specified window(s). If you use the kitty @ signal-child --match option the title will be set for all matched windows. By default, only the active window is affected. If you do not specify any signals, SIGINT is sent by default. You can also map this to a keystroke in kitty.conf, for example:

map F1 signal_child SIGTERM

Options

--match <MATCH>, -m <MATCH>

The window to match. Match specifications are of the form: field:regexp. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent. You can use the ls command to get a list of windows. Note that for numeric fields such as id, pid, recent and num the expression is interpreted as a number, not a regular expression. The field num refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the ls command). The window id of the current window is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on. When using the env field to match on environment variables you can specify only the environment variable name or a name and value, for example, env:MY_ENV_VAR=2