Cloning and Integration
Kitty lets you clone your current shell environment — working directory, SSH connection, and all — into a new window or tab. Combined with editor integration, this creates a seamless development workflow.
Use cloning to duplicate your exact shell context, integrate kitty with vim/neovim for image display, and pipe output between applications.
Cloning: Duplicate Your Shell Context
The clone feature duplicates your current shell's working directory and environment into a new kitty window, tab, or OS window.
How to Clone
| Shortcut | Action |
|---|---|
Ctrl+Shift+Alt+l | Clone current shell into a new window |
Ctrl+Shift+Alt+t | Clone current shell into a new tab |
Ctrl+Shift+Alt+w | Clone current shell into a new OS window |
Using Remote Control to Clone
# Clone current window into a new tab with same cwd
kitty @ launch --type=tab --cwd=current
# Clone into a new OS window
kitty @ launch --type=os-window --cwd=current
# Clone with a specific program
kitty @ launch --type=window --cwd=current vim
# Clone with environment variable override
kitty @ launch --type=window --cwd=current --env MODE=debug bash
Clone with Different Layout
# Clone into a split pane (right)
kitty @ launch --type=window --cwd=current --location=hsplit
# Clone into a split pane (bottom)
kitty @ launch --type=window --cwd=current --location=vsplit
Clone Across SSH
When connected via SSH, cloning preserves the SSH connection:
# On a remote server via kitty +kitten ssh:
# Clone will open a new window also connected to the remote
kitty @ launch --type=window --cwd=current
Editing Remote Files Locally
The remote_file kitten lets you open remote files in your local editor:
# Open a remote file locally
kitty +kitten remote_file user@server:/etc/nginx/nginx.conf
# Specify which editor to use
EDITOR=vim kitty +kitten remote_file user@server:/srv/myapp/config.yml
This downloads the file, opens it in your local editor, and uploads the changes when you save and close.
Integration with Vim/Neovim
Image Display in Neovim
With the kitty graphics protocol, neovim can display images inline:
" In your init.vim / init.lua
" Requires a plugin like image.nvim
Plug 'adelarsq/image.nvim'
" Or use kitty's built-in icat
:!kitty +kitten icat --place 80x40@0x0 image.png
Clipboard Integration
Kitty shares clipboard with vim/neovim automatically:
" Yank to kitty's clipboard
"+y " Yank to system clipboard via kitty protocol
" Paste from kitty clipboard in insert mode
<Ctrl+Shift+v>
Configure Neovim for Kitty
-- Detect kitty terminal
if vim.env.TERM == 'kitty' then
-- Enable kitty protocol features
vim.g.kitty_term = true
-- Better mouse support
vim.opt.mouse = 'a'
-- True color support
vim.opt.termguicolors = true
end
Integration with File Managers
ranger
# Open images in kitty using icat
image/*, video/*, font/*, image/x-eps, application/pdf
flag f = kitty +kitten icat --place 80x40@0x0 "$@"
lf (terminal file manager)
&kitty +kitten icat --clear 2>/dev/null; kitty +kitten icat --place ${w}x${h}@${x}x${y} $f
previewer:
kitty +kitten icat --place ${w}x${h}@${x}x${y} $f
fzf integration
# Use fzf with kitty previews
fzf --preview 'kitty +kitten icat --place 60x30@0x0 {} 2>/dev/null || cat {}'
The Piping Environment
Kitty can launch with piping, connecting output between programs:
# Launch a new window that receives piped input
echo "hello" | kitty @ launch --type=window --stdin-source=@last stdout
# Launch with a command that reads from stdin
kitty @ launch --type=window --stdin-source=@last vim -
Real-World Example: Development Workflow
#!/bin/bash
# Clone the current environment into a development layout
SESSION_DIR=$(pwd)
SESSION_NAME=$(basename "$SESSION_DIR")
# Create a tab with the dev layout
kitty @ launch --type=tab --cwd=current --title "$SESSION_NAME:editor"
kitty @ launch --type=window --cwd=current --title "$SESSION_NAME:terminal"
kitty @ launch --type=window --cwd=current --title "$SESSION_NAME:logs"
echo "Development layout created in new tab"
Integration with Other Tools
| Tool | Integration Method | Use |
|---|---|---|
| Vim/Neovim | kitty @ send-text, clipboard sharing | Edit in kitty with full graphics support |
| ranger/lf | Icat preview | Image preview in file manager |
| fzf | kitty +kitten icat preview | Fuzzy find with image preview |
| tmux | kitty @ launch inside tmux | Nest kitty features within tmux sessions |
| SSH | kitty +kitten ssh | Remote shells with full protocol |
| Git | kitty +kitten diff as difftool | Visual git diffs |
Common Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Clone creates new cwd instead of current | New window at $HOME | Use --cwd=current explicitly |
| Remote file kitten asks for password repeatedly | SSH auth not cached | Use SSH key-based auth or ssh-agent |
| Icat in neovim shows garbled output | Image protocol conflict | Use --transfer-mode=stream or update neovim plugin |
| Clone across SSH loses connection | Clone creates local window | Ensure kitty +kitten ssh was used to connect |
| fzf preview shows text instead of image | Icat not in PATH | Use full path: /usr/bin/kitty +kitten icat |
Hands-On Practice
# Test cloning
kitty @ launch --type=window --cwd=current --title "cloned-shell"
# Test launching with a specific program
kitty @ launch --type=window --cwd=current vim
# Test piping environment
echo "Hello from piped input" | kitty @ launch --type=window --stdin-source=@last cat
# Test remote_file (if you have SSH access to localhost)
echo -e "key=value\nport=8080" > /tmp/test-remote.conf
kitty +kitten remote_file localhost:/tmp/test-remote.conf
# Clean up
rm /tmp/test-remote.conf 2>/dev/null