Drag and DropΒΆ

The dnd kitten can be used to drag and drop files between the shell and arbitrary GUI programs, it even works over SSH, so you can easily and seamlessly transfer files from one computer to another, simply by dragging from one kitty window to another. Using it is as simple as:

kitten dnd file-to-drag.xyz

Then, start dragging with the mouse inside the window, and file-to-drag.xyz will be dragged and you can drop it onto a GUI file manager or another window running this kitten. You can specify directories as well to drag entire trees.

Similarly, dropping works by running the kitten:

kitten dnd

Then, drag some files from a GUI file manager or another window running the dnd kitten and drop them onto this window. The files will be copied or moved (depending on which area you drop them) into the current working directory.

The best part is this works even over SSH. So if you just want to quickly transfer some files from one computer to another all you need to so is ssh into the remote computer:

kitten ssh remote-computer-name

Then, run the dnd kitten on the remote computer:

kitten dnd files-or-dirs-to-drag

That’s it, you can now drag form or drop to the remote computer. See below for customising the behavior of the kitten via command line flags.

This kitten uses a new protocol developed by kitty to function, for details, see The Drag and Drop protocol.

Source code for dndΒΆ

The source code for this kitten is available on GitHub.

Command Line InterfaceΒΆ

kitten dnd [options] [files to drag]

Perform drag and drop operations, even over SSH.

Any arguments on the command line are assumed to be files and directories to drag. They will be dragged as the text/uri-list MIME type which can then be dropped into any file manager or similar program to copy the files.

If the text/uri-list MIME type is dropped onto this window, the files and directories in it are copied into the current working directory. When dragging from this window, if a move operation is performed when dropping and the drop is to a remote machine, the files and directories to drag and deleted.

If data is present on STDIN it is set as text/plain when dragging, unless text/plain is specified via --drag. Any text/plain data that is dropped onto this window is output to STDOUT, if STDOUT is connected to a file, otherwise it is discarded.

Press the Esc or Ctrl+C keys to quit the kitten at any time, cancelling any in progress drag.

OptionsΒΆ

--drag <DRAG>ΒΆ

When starting a drag, use the specified file as the data source for the specified MIME type. Syntax is: mime-type:path/to/file. For example image/jpeg:mypic.jpg Can be specified multiple times to drag multiple MIME types.

--drop <DROP>ΒΆ

When receiving a drop, use the specified file as the data destination for the specified MIME type. Syntax is: mime-type:path/to/file. For example image/jpeg:mypic.jpg Can be specified multiple times to enable receiving multiple MIME types. If no path is specified, it will prevent that MIME type being dropped, useful to disable accepting text/plain and text/uri-list.

--drop-dest <DROP_DEST>ΒΆ

Path to the directory in which dropped data is saved. Defaults to the current working directory.

--confirm-drop-overwrite [=no]ΒΆ

Ask for confirmation when dropping text/uri-list data if the drop will cause any existing files to be overwritten. Note that confirmation is asked only for actual file conflicts, non conflicting files are automatically created.

--drop-anywhere <DROP_ANYWHERE>ΒΆ

Allow dropping anywhere, not just on the Copy or Move drop regions. Dropping anywhere will perform the specified action. Default: disallowed Choices: copy, disallowed, move

--drag-thumbnail <DRAG_THUMBNAIL>ΒΆ

Path to an image to use as the drag icon when starting a drag. Must be in PNG/JPEG/GIF/WEBP formats. Other formats will require the presence of ImageMagick on the system to load the image. If not specified, an image is derived based on the data being dragged.

--drag-thumbnail-size <DRAG_THUMBNAIL_SIZE>ΒΆ

The thumbnail size for the image used as the drag icon. Images larger than this size are downscaled. Note that the terminal may reject the drag if the image is too large. Default: 512

--exit-on <EXIT_ON>ΒΆ

A comma separated list of events to exit on. Possible events are drag-finish, drop-finish and esc-key. The first two events refer to a successful completion of a drag or a drop respectively. esc-key means press the Esc key. Default: esc-key