Skip to content
parisniPublic

About

helix on steroids with kitty

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

84 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

kittyx

Seamless workflow integration for Helix editor: Git operations, live search, file browsing, and text replacement with automatic file opening via Kitty overlay windows.

Helix's design philosophy embraces simplicity without plugins, following Unix principles of composing specialized tools. Rather than constraining functionality within Helix's limited buffer system, this project leverages Kitty terminal's powerful windowing to integrate best-in-class tools like fzf, yazi, scooter or lazygit. Each tool excels in its domain, providing capabilities no plugin could match.

Features

Keybinding Mode Description Script
space-g-b Normal Git blame with PR/commit URLs kittyx-git-blame
space-g-f Normal Interactive git file browser with commit history kittyx-tab git-file
space-g-g Normal Interactive git browser (lazygit) kittyx-tab git
space-g-l Normal Interactive git log browser kittyx-tab git-log
space-g-u Normal Copy Git URL to clipboard (cursor line) kittyx-git-url-copy
space-g-o Normal Open Git URL in browser (cursor line) kittyx-git-url-open
space-e Normal File browser (yazi) - manipulate selected file kittyx-tab tree
space-/ Normal Live grep search - opens selected file kittyx-tab live-grep
space-/ Select Live grep with selected text as query - opens selected file kittyx-tab live-grep
space-? Normal Structural search (ast-grep) - opens selected file kittyx-tab ast-grep
space-? Select Structural search with selected text as pattern - opens selected file kittyx-tab ast-grep
C-S-f Tree Live grep within selected folder - opens selected file kittyx-tab live-grep
C-S-r Tree Replace text within selected folder kittyx-tab replace
C-S-g Tree Git history for selected file/folder kittyx-tab git-browse
space-r Normal Replace in current file kittyx-replace
space-R Normal Replace across project kittyx-replace
space-r Select Replace selected text in current file kittyx-replace
space-R Select Replace selected text across project kittyx-replace
ctrl-space Kitty View scrollback buffer in Helix overlay kittyx-scrollback
alt-space Kitty View a prompt and its output in Helix overlay: the selected one, else the typed one (--typed), else the last one with output kittyx-scrollback --cmd
alt-[ / alt-] Kitty Select the previous / next prompt for alt-space and scroll it to the top kittens/prompts.py prev / next
ctrl-/ Kitty Toggle a companion shell behind the current window kittens/companion.py
ctrl-shift-/ Kitty Close the companion shell kittens/companion.py close
alt-j / alt-k Kitty Focus companion / parent, then the next window-manager window kittens/companion.py down / up
space-g-r-c Normal/Select Buffer a review comment on the cursor line or selected lines kittyx-review comment
space-g-r-p Normal Browse, edit or delete buffered review comments kittyx-review pending
space-g-r-f Normal End the review in an overlay: post, write notes or abandon, then remove the worktree kittyx-review flush --overlay

Core Features

Enhanced Git Blame

  • Smart PR/commit URL detection: Automatically detects and shows PR URLs when available, falls back to commit URLs
  • Multi-platform support: GitHub, GitLab, Bitbucket, Azure DevOps, and Gerrit
  • Platform-specific patterns: Recognizes different PR formats (#123 for GitHub, !123 for GitLab, Change-Id for Gerrit)
  • Rich output: Shows author, time since commit, commit message, and clickable URL
  • URL-only mode: --url-only flag for integration with other tools

Git Browser Integration

  • Lazygit integration: Full-featured git interface in an overlay over Helix
  • Open from lazygit: with --open-in-helix, lazygit's edit (e) closes the overlay and opens the file at the selected line in Helix
  • Git log browser: Interactive commit history with fzf
  • Modified files browser: Interactive browser for git status files

File Browser (Yazi Integration)

  • Interactive file browser: Full-featured yazi file manager in an overlay over Helix
  • Smart directory detection: Opens from current buffer's directory or specified path
  • Seamless file opening: Selected files automatically open in Helix after the overlay closes
  • Live grep integration: Press Shift+Ctrl+F in yazi to search within the current directory
  • Unified workflow: Both yazi selection and live-grep from yazi work seamlessly together

Live Grep Search

  • Interactive ripgrep with fzf interface in an overlay over Helix
  • ripgrep runs on the typed query (fixed string, smart case, 3 chars minimum), so large repos are never piped whole into fzf
  • Closest matches first: searches the current buffer's directory, then each parent up to the git root (--start-from)
  • ctrl-t toggles between ripgrep and fzf filtering of the current results
  • Copy file:line references with ctrl-y
  • Selection mode prepopulates search query
  • Seamless file opening: Selected files automatically open in Helix after the overlay closes
  • Rich syntax highlighting in preview
  • Single file selection only (no multi-select)

Structural Search (ast-grep)

Where live grep matches text, this matches code shape. You write a snippet in the target language with metavariables standing in for the parts you don't care about, so $A($$$ARGS) finds every call regardless of name or argument count — no regex gymnastics, no matches inside comments or strings.

  • $A — exactly one node (an expression, an identifier, an argument). Named, so bar($A, $A) requires both to be identical.
  • $$$ARGS — zero or more nodes (an argument list, a function body). Bare $$$ works too, except on its own.
  • The pattern must be syntactically complete: foo( matches nothing, foo($$$) works. Incomplete patterns while typing simply yield an empty list.

The search re-runs on each keystroke once the query reaches 3 characters (--min-chars), since a shorter pattern matches nearly every node. The language is inferred from the file extension; add a lang: token to the query to restrict it, as in $A.$B($$$C) lang:java,py. Markdown files are excluded — its grammar has no call expressions, so any pattern would match arbitrary prose.

With --start-from, the search starts in the current buffer's directory, then widens to each parent up to the git root, so the closest matches come first while the rest of the repo streams in. ctrl-t toggles to fzf filtering of the current results, to narrow them down without re-running a repo-wide search.

Beware that ast-grep matches a syntactic shape, not text: check($A) finds calls only, never the def check(x) that declares it, and it excludes both check() and obj.check(x). Use def check($A): $$$B for the declaration and $X.check($$$) for method calls.

Requires the ast-grep binary, invoked as ast-grep: the short sg alias collides with the setgid sg from shadow-utils. Full pattern reference: the syntax guide and playground.

Text Replacement (Scooter Integration)

  • File-scoped replacement: Replace in current file with interactive preview
  • Project-wide replacement: Replace across entire project with scooter integration
  • Selection-aware: Works with selected text in Helix

Scrollback Viewer

  • Terminal scrollback integration: View terminal scrollback buffer in Helix overlay
  • Command output viewer: With --cmd <window id>, view a command and its output in Helix overlay, cut from the scrollback at the shell integration prompt marks. Lines above the last prompt line (multi-line prompt decorations) are dropped, as input starts on it. It shows, in order:
    • the prompt selected with kittens/prompts.py (alt-[ / alt-], one prompt at a time from the last, prompts without output included), until a command runs or, with the zsh hook below, the command line is edited;
    • with --typed, the current prompt when it holds input. Input is detected as text below the prompt's first line: it fits a two-line prompt whose input line shows no prompt symbol (e.g. powerlevel10k without prompt_char), and misfires with a symbol such as $ or ❯;
    • else the last prompt whose output is not empty.
  • Smart cursor positioning: Positions at cursor location for vim/less windows, jumps to end for other content
  • Custom keybindings: Inherits your Helix config with added q key for force quit
  • Fast temporary files: Uses /dev/shm when available (falls back to $TMPDIR on macOS)

Markdown Preview

  • Live preview: Converts markdown to HTML with automatic browser opening
  • GitHub styling: Uses GitHub markdown CSS for consistent appearance
  • Isolated serving: Each markdown file gets its own preview directory
  • Live reload: Uses live-server for automatic refresh on changes
  • Pandoc integration: Full-featured markdown conversion with self-contained HTML

Companion Shell

  • Hidden layer: one shell per window (e.g. Helix), in the same tab; with the stack layout only one of the two is visible, ctrl-/ flips between them
  • Right directory: starts in the parent's working directory (--cwd=current)
  • Window-manager agnostic: lives inside kitty, so it works the same on Linux (sway/i3) and macOS
  • Pair-aware focus: alt-j goes from the parent to its companion and alt-k back; past that edge (or without a companion) the kitten runs swaymsg/i3-msg focus down|up, so these keys must not be bound in sway/i3
  • Discoverable: tagged with the kittyx_companion=<parent window id> user variable, so other tools (e.g. dfzf) can list or target it

Code Review (GitHub, GitHub Enterprise, Gerrit and local branches)

  • Three forges: github.com and GitHub Enterprise pull requests (https://<host>/<owner>/<repo>/pull/<N>, through gh), Gerrit changes (https://<host>/c/<project>/+/<N>, through the REST API and ~/.netrc)
  • Offline-first: kittyx-review <url> (alias of open <url>) checks the PR or change out in a worktree reset to its base and starts Helix there: the whole change shows as unstaged (space-g-c, or lazygit with space-g-g) and every file is at the reviewed version; from a terminal only, an agent just gets the review printed; --tab opens Helix in a new kitty tab instead, from anywhere (e.g. an agent)
  • Whole change by default: a PR from its merge-base with the target branch, a Gerrit change with its relation chain from their merge-base with origin/<target branch> (--base <ref> for another ref); --last narrows it to the head commit or the change alone
  • Pinned: a review stays on the head it was opened at; open warns STALE on a newer one, flush then open reviews it
  • Comment from Helix: the Helix line is the line to comment on; space-g-r-c edits the body in a kitty overlay and buffers it as JSON in <worktree>/.gh-review-pending/, nothing is posted yet
  • One grouped review: kittyx-review flush posts every buffered comment and the verdict at once (COMMENT or APPROVE, never blocking), --dry-run prints the payload; on a Gerrit chain each comment goes to the newest change modifying its file, and APPROVE votes Code-Review +2 on every change
  • Flush ends the review: the verdict menu is the only prompt; once the buffer is empty the worktree is removed, ABANDON removes it without posting
  • Notes for the agent: the NOTES verdict posts nothing and writes the comments as markdown notes, any file allowed, kept in the clone's .git/kittyx-review/notes/ so they outlive the worktree; kittyx-review notes <url> prints the unread ones, for the agent that answers the review
  • Safe anchors: GitHub comments off the PR net diff and Gerrit lines past the end of the file or outside the chain stay in the buffer instead of breaking the review
  • Bookkeeping: ls lists the reviews in progress and their unposted comments
  • Agent friendly: open without a terminal, ls --json, comment --body-file and flush --event run without a terminal
  • Local branches: kittyx-review alone (alias of local), or kittyx-review local [<branch>] [--base <ref> | --last], reviews a committed branch of the current repo (default: the current one) against its merge-base with origin/HEAD (or its head commit only); flush writes the comments as markdown notes, and kittyx-review notes, run from the dev repo, prints those not read yet so the agent that wrote the branch can address them
  • In place: comment in any other git repo reviews its working tree as it is, uncommitted changes included; flush writes notes quoting the code at comment time, notes reads them with those of a local review of the branch; the flush drops the buffer and leaves the repo alone
kittyx-review https://github.com/owner/repo/pull/123      # helix in the worktree
kittyx-review https://ghe.example.com/owner/repo/pull/45
kittyx-review https://review.example.com/c/project/+/6789 --last
kittyx-review flush --dry-run             # from inside the review worktree
kittyx-review flush --event APPROVE       # posts, then removes the worktree
kittyx-review flush --event ABANDON       # removes it without posting

kittyx-review                             # current branch, from the dev repo
kittyx-review flush                       # from the review worktree: writes the notes
kittyx-review notes                       # from the dev repo: unread notes

Installation

  1. Clone the repository:

    git clone https://github.com/parisni/kittyx.git
  2. Add the bin/ directory to your PATH:

    export PATH="$PATH:/path/to/kittyx/bin"
  3. Add the key mappings to your Helix config.toml:

Configuration

Add the following key mappings to your Helix configuration file (~/.config/helix/config.toml):

[keys.normal.space]
# Live grep search with automatic file opening
"/" = [":open %sh{kittyx-tab live-grep --start-from '%{buffer_name}'}"]

# Structural search (ast-grep) with automatic file opening
"?" = [":open %sh{kittyx-tab ast-grep --start-from '%{buffer_name}'}"]

# Git operations
g = { "b" = ":sh kittyx-git-blame %{buffer_name} %{cursor_line}", "f" = ":sh kittyx-tab git-file %{buffer_name}", "l" = ":sh kittyx-tab git-log", "u" = ":sh kittyx-git-url-copy %{buffer_name} %{cursor_line}", "o" = ":sh kittyx-git-url-open %{buffer_name} %{cursor_line}", "g" = ":sh kittyx-tab git" }

# File browser with automatic file opening
e = ":open %sh{kittyx-tab tree '%{buffer_name}'}"


# Text replacement
R = [ ":write-all", ":sh kittyx-tab replace", ":reload-all" ]
r = [ ":write-all", ":sh kittyx-tab replace %{buffer_name}", ":reload-all" ]

[keys.select.space]
# Live grep with selected text as query  
"/" = [":pipe tee /tmp/kittyx-live-grep-query", ":open %sh{kittyx-tab live-grep --start-from '%{buffer_name}'}"]

# Structural search with selected text as pattern
"?" = [":pipe tee /tmp/kittyx-ast-grep-query", ":open %sh{kittyx-tab ast-grep --start-from '%{buffer_name}'}"]

# Text replacement with selection
r = [ ":pipe tee /tmp/kittyx-replace.tmp", ":sh kittyx-tab replace %{buffer_name}", ":reload-all" ]
R = [ ":pipe tee /tmp/kittyx-replace.tmp", ":sh kittyx-tab replace", ":reload-all" ]

Kitty Configuration

Add the following to your Kitty configuration file (~/.config/kitty/kitty.conf):

# Scrollback viewer with Helix
map ctrl+space launch --type=overlay --title=current --stdin-source=@screen_scrollback kittyx-scrollback
map alt+space launch --type=overlay --title=current --stdin-source=@screen_scrollback --stdin-add-formatting kittyx-scrollback --cmd @active-kitty-window-id
# Prompt selection for alt+space; full-screen programs get the key passed as last argument
map alt+[ kitten /path/to/kittyx/kittens/prompts.py prev alt+[
map alt+] kitten /path/to/kittyx/kittens/prompts.py next alt+]

# Companion shell (needs the stack layout; kittens run inside kitty, no remote control required)
enabled_layouts stack
map ctrl+slash       kitten /path/to/kittyx/kittens/companion.py
map ctrl+shift+slash kitten /path/to/kittyx/kittens/companion.py close
# Replaces the WM's alt+j/alt+k focus bindings (remove those from sway/i3)
map alt+j kitten /path/to/kittyx/kittens/companion.py down
map alt+k kitten /path/to/kittyx/kittens/companion.py up

Optionally, in ~/.zshrc, void the alt-space prompt selection as soon as the command line is edited, so typed input wins over it (--typed):

if [[ -n ${KITTY_WINDOW_ID-} ]]; then
  function _kittyx_prompt_unselect() {
    [[ $BUFFER == ${_kittyx_buffer-} ]] && return
    typeset -g _kittyx_buffer=$BUFFER
    print -n '\e]1337;SetUserVar=kittyx_prompt\a'
  }
  autoload -Uz add-zle-hook-widget
  add-zle-hook-widget line-pre-redraw _kittyx_prompt_unselect
fi

Lazygit Configuration

To open files from lazygit (e) in the calling Helix, call git-browse with --open-in-helix through :open, e.g. "g" = ":open %sh{kittyx-tab git-browse --open-in-helix --status}", and add to ~/.config/lazygit/config.yml:

os:
  edit: 'kittyx-git-edit -- {{filename}}'
  editAtLine: 'kittyx-git-edit --line {{line}} -- {{filename}}'
  editInTerminal: true

Outside --open-in-helix (lazygit started elsewhere), kittyx-git-edit opens the files in hx.

Review Configuration

Review keys for Helix (space-g-r must not clash with another space-g binding):

[keys.normal.space.g.r]
c = ":sh kittyx-review comment %{buffer_name} %{selection_line_start} %{selection_line_end}"
p = ":open %sh{kittyx-review pending --open-in-helix %{buffer_name}}"
f = ":sh kittyx-review flush --overlay %{buffer_name}"

[keys.select.space.g.r]
c = ":sh kittyx-review comment %{buffer_name} %{selection_line_start} %{selection_line_end}"

Paths go in ~/.config/kittyx/review.conf (sourced as bash, every key optional); hosts come from the review URL:

GERRIT_USER=$USER                       # ssh user of the Gerrit clone hint
REVIEW_WORKTREE_ROOT=~/.local/share/kittyx/reviews
REPO_ROOTS="$HOME/git"                  # local clones: <root>/<repo name>

open adds a worktree to the local clone whose origin matches the review; it never clones by itself.

Yazi Configuration

For enhanced yazi integration, add the following to your yazi keymap configuration file (~/.config/yazi/keymap.toml):

[[mgr.prepend_keymap]]
on   = "<S-C-f>"
run  = 'shell -- kittyx-tab live-grep --open-in-helix --quit-tree --filepath %h'
desc = "Live grep on the given folder"

[[mgr.prepend_keymap]]
on   = "<S-C-r>"
run  = 'shell -- kittyx-tab replace --quit-tree --filepath %h'
desc = "Replace text in the given folder"

[[mgr.prepend_keymap]]
on   = "<S-C-g>"
run  = 'shell -- kittyx-tab git-browse --filepath %h'
desc = "Git history for the selected file/folder"

This enables:

  • Shift+Ctrl+F in yazi: Launch live grep search in the current directory
  • Shift+Ctrl+R in yazi: Launch text replacement in the current directory
  • Shift+Ctrl+G in yazi: View git history for the selected file/folder
  • Automatic integration: Search results open directly in Helix, replacements work within selected directory
  • Smart cleanup: Yazi automatically closes after file selection

Requirements

About

helix on steroids with kitty

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages