Skip to content

Automatic shell integration for zsh, fish and PowerShell - #1923

Merged
raphamorim merged 12 commits into
mainfrom
shell-integration-v2
Sep 17, 2026
Merged

raphamorim merged 12 commits into
mainfrom
shell-integration-v2

Conversation

@raphamorim

@raphamorim raphamorim commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Rio's title path variables and cwd inheritance rely on the shell reporting its working directory, but until now that required the user to configure their shell. This PR makes it work out of the box on every platform:

  • Rio embeds small integration scripts and injects them automatically at spawn. zsh and fish load through the environment alone: ZDOTDIR for zsh (the user's value is preserved and restored before any of their configuration runs, and their real .zshenv is chained first) and an XDG_DATA_DIRS prepend for fish (vendor_conf.d). The scripts emit OSC 7 on every prompt and directory change and are original to rio.
  • PowerShell (powershell.exe and pwsh, on Windows and unix) has no environment hook, so a bare spawn is rewritten to -NoExit -Command . '<script>', running after the user's profile, the same mechanism VS Code uses for automatic injection. Configured shell args win over integration and skip the rewrite. The script wraps the prompt function and emits the cwd as a file:// URI, so spaces and UNC paths are handled by the existing parser rules (remote UNC hosts are refused).
  • Scripts are written under the cache directory once per rio version, so upgrades refresh them and installs need no packaging changes.
  • The OSC 7 parser now also accepts the kitty-shell-cwd:// scheme (a raw, unencoded path), so existing kitty-style shell integrations work with rio unchanged.
  • New: OSC 9;9 (ConEmu/Windows Terminal working directory) is parsed as a cwd report. Previously it fell into the desktop-notification fallback and produced a bogus notification; now any existing Windows Terminal $PROFILE works with rio as-is.
  • create_pty_with_fork gained an env parameter so the fork spawn path (use-fork = true) injects the same environment as the spawn path; the Windows ConPTY path already supported env blocks and needed no teletypewriter change.
  • New config option shell-integration (default true) disables the injection entirely.

Out of scope: bash needs --posix plus ENV argv surgery, cmd.exe only offers a machine-wide registry AutoRun (too invasive; clink users can source a snippet), nushell's vendor autoload story is still settling across versions, and WSL needs WSLENV plumbing. All are documented paths for a follow-up.

Tests: parser acceptance/verbatim/host-rejection for kitty-shell-cwd://, OSC 9;9 parsing (quoted paths, ; rejoin, non-collision with progress reports), per-shell env mapping, cross-platform shell-name normalization, PowerShell path quoting, and idempotent script materialization.

@raphamorim raphamorim changed the title Automatic shell integration for zsh and fish Automatic shell integration for zsh, fish and PowerShell Sep 7, 2026
@raphamorim
raphamorim merged commit 510897a into main Sep 17, 2026
1 check passed
@raphamorim
raphamorim deleted the shell-integration-v2 branch September 17, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant