Launching programs in new windows/tabs

kitty has a launch action that can be used to run arbitrary programs in news windows/tabs. It can be mapped to user defined shortcuts in kitty.conf. It is very powerful and allows sending the contents of the current window to the launched program, as well as many other options.

In the simplest form, you can use it to open a new kitty window running the shell, as shown below:

map f1 launch

To run a different program simply pass the command line as arguments to launch:

map f1 launch vim path/to/some/file

To open a new window with the same working directory as the currently active window:

map f1 launch --cwd=current

To open the new window in a new tab:

map f1 launch --type=tab

To pass the contents of the current screen and scrollback to the started process:

map f1 launch --stdin-source=@screen_scrollback less

There are many more powerful options, refer to the complete list below.

The piping environment

When using launch --stdin-source, the program to which the data is piped has a special environment variable declared, KITTY_PIPE_DATA whose contents are:

KITTY_PIPE_DATA={scrolled_by}:{cursor_x},{cursor_y}:{lines},{columns}

where scrolled_by is the number of lines kitty is currently scrolled by, cursor_(x|y) is the position of the cursor on the screen with (1,1) being the top left corner and {lines},{columns} being the number of rows and columns of the screen.

Syntax reference

launch [options] [program-to-run ...]

Launch an arbitrary program in a new kitty window/tab. Note that if you specify a program-to-run you can use the special placeholder @selection which will be replaced by the current selection.

Options

--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 actie 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 none means the process will be run in the background. The values clipboard and primary are meant to work with 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.

--location <LOCATION>

Where to place the newly created window when it is added to a tab which already has existing windows in it. Also applies to creating a new tab, where the value of neighbor will cause the new tab to be placed next to the current tab instead of at the end. Default: last Choices: first, last, neighbor

--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 launch --stdin-source add formatting escape codes, without this only plain text will be sent.

--stdin-add-line-wrap-markers

When using 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.