Shell Integration Basics
Shell integration connects kitty with your shell to provide prompt-aware scrolling, mark-based navigation, and scrollback annotations.
Enable shell integration in your shell configuration to unlock prompt jumping, command output marks, and structured scrollback navigation.
What Shell Integration Provides
When enabled, kitty understands the structure of your terminal session — it knows where prompts begin, where command output ends, and can navigate based on that structure.
| Feature | Benefit |
|---|---|
| Prompt marks | Jump between shell prompts with keyboard shortcuts |
| Command marks | Mark each command's output for navigation |
| Scrollback annotations | Kitty annotates the scrollback buffer for structured access |
| Cursor sync | Scroll the viewport without losing your prompt position |
| Output streaming | See command output in real time with synchronized scrolling |
How It Works
┌──────────────────────────────────────────────────────┐
│ Terminal Window │
│ │
│ $ git status ← Prompt (marked) │
│ On branch main │
│ Your branch is up to date... ← Command output │
│ │
│ ──── mark ──── │
│ │
│ $ docker compose up -b ← Next prompt (marked)│
│ [+] Building 0.5s │
│ [+] Running 2/2 │
│ ✔ Container app Started │
│ ✔ Container db Started ← Output │
│ │
└──────────────────────────────────────────────────────┘
▲ ▲
│ │
Ctrl+Shift+up/down Ctrl+Shift+h
(jump by mark) (search scrollback)
Kitty uses OSC escape codes (Operating System Command sequences) to communicate with the shell. When your shell outputs a prompt, kitty detects the OSC code and records the position as a mark.
Enabling Shell Integration
For Bash
Add to ~/.bashrc:
# Enable kitty shell integration
if [ -n "$KITTY_SHELL_INTEGRATION" ]; then
source "$HOME/.local/kitty/shell-integration/bash/kitty.bash"
fi
For Zsh
Add to ~/.zshrc:
# Enable kitty shell integration
if [ -n "$KITTY_SHELL_INTEGRATION" ]; then
source "$HOME/.local/kitty/shell-integration/zsh/kitty.zsh"
fi
For Fish
Add to ~/.config/fish/config.fish:
# Enable kitty shell integration
if set -q KITTY_SHELL_INTEGRATION
source "$HOME/.local/kitty/shell-integration/fish/kitty.fish"
end
The $KITTY_SHELL_INTEGRATION environment variable is set automatically by kitty when it launches a shell. The check ensures the integration only loads when running inside kitty.
Verify It Is Working
After sourcing the integration file, run:
echo $KITTY_SHELL_INTEGRATION
# Should output: enabled
Quick Test
# Source the integration (adjust path for your shell)
source "$HOME/.local/kitty/shell-integration/bash/kitty.bash" 2>/dev/null || \
echo "Integration file not found. Is kitty installed?"
# Now run a few commands
ls -la
echo "hello"
pwd
# Try jumping between prompts
# Press: Ctrl+Shift+up / Ctrl+Shift+down
OSC Escape Codes Used
| Code | Purpose | Sent By |
|---|---|---|
OSC 133 ; A ST | Prompt start (before prompt) | Shell integration |
OSC 133 ; B ST | Prompt end (after prompt) | Shell integration |
OSC 133 ; C ST | Command start | Shell integration |
OSC 133 ; D ST | Command end | Shell integration |
OSC 133 ; L ST | Title/description for a mark | Kitty or manual |
Shell Integration Options
Control which features are enabled:
# Enable all features
export KITTY_SHELL_INTEGRATION="enabled"
# Enable only specific features
export KITTY_SHELL_INTEGRATION="enabled no-cursor no-prompt-mark"
Available feature flags:
| Flag | What It Disables |
|---|---|
no-cursor | Disable cursor synchronization |
no-prompt-mark | Disable prompt mark annotations |
no-output-stream | Disable output streaming |
Supported Shells
| Shell | Status | Integration File Location |
|---|---|---|
| Bash | ✅ Full support | ~/.local/kitty/shell-integration/bash/kitty.bash |
| Zsh | ✅ Full support | ~/.local/kitty/shell-integration/zsh/kitty.zsh |
| Fish | ✅ Full support | ~/.local/kitty/shell-integration/fish/kitty.fish |
Common Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Integration not sourced before prompt | Prompt marks not appearing | Source before setting PS1 in .bashrc |
| Double-sourcing the integration | Duplicate marks, slowdown | Guard with [[ -z $KITTY_SHELL_INTEGRATION ]] check |
Using $PROMPT_COMMAND that clears marks | Marks lost after each command | Chain $PROMPT_COMMAND instead of overwriting |
| Remote SSH sessions without integration | No marks on remote | Install kitty or copy shell-integration files to remote |
| Fish integration not loading | Shell integration file not found | Verify fish version >= 3.0 |
Hands-On Practice
# Locate the shell integration file for your shell
ls -la "$HOME/.local/kitty/shell-integration/" 2>/dev/null || \
echo "Kitty not found at default path"
# If kitty is installed, test sourcing
if [ -f "$HOME/.local/kitty/shell-integration/bash/kitty.bash" ]; then
source "$HOME/.local/kitty/shell-integration/bash/kitty.bash"
echo "Shell integration activated for this session"
fi
# Verify
echo "KITTY_SHELL_INTEGRATION=$KITTY_SHELL_INTEGRATION"