Wrap shell-integration OSCs in tmux DCS-passthrough#197
Draft
dakra wants to merge 1 commit into
Draft
Conversation
When a user runs ghostel's shell integration inside tmux (without control-mode integration), tmux strips OSC sequences before they reach ghostel. The shell emits OSC 7, but `default-directory' never updates, so `find-file' and friends don't follow the shell's cwd. Reported in issue #195. Fix: when `$TMUX' is set, the shell integration wraps every OSC in tmux's DCS-passthrough envelope (`\ePtmux;<body-with-doubled-ESCs>\e\\'). tmux unwraps one level and forwards the bare OSC to ghostel. Users opt in by adding `set -g allow-passthrough on' to `~/.tmux.conf' (tmux 3.3+); without that, tmux drops the wrapped sequence — same behavior as before, no regression. A single `__ghostel_emit_osc' helper in each of the bash/zsh/fish integration files takes the OSC body and emits either the bare `\e]<body>\e\\' or the wrapped form, depending on `$TMUX'. The five existing emitters (`__ghostel_osc7', `__ghostel_prompt_start', `__ghostel_prompt_end', `__ghostel_preexec', `ghostel_cmd') route through it. Byte output is identical across all three shells; fish's helper needs extra escaping because fish's single-quote consumes one level of `\\' → `\' before printf sees it. Tests: new `ghostel-test-shell-osc-tmux-wrapping' (elisp suite) spawns each shell, sources the integration with and without `$TMUX', and asserts byte-exact output. README gains an "Inside tmux" subsection documenting the `allow-passthrough' requirement and the `INSIDE_EMACS'-propagation caveat. Refs #195
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
$TMUXis set, the bash/zsh/fish shell integration wraps every OSC sequence (OSC 7 cwd, OSC 133 prompt markers, OSC 51ghostel_cmd) in tmux's DCS-passthrough envelope (\ePtmux;<body-with-doubled-ESCs>\e\\). tmux unwraps one level and forwards the body to ghostel, restoring directory tracking and prompt navigation inside plain tmux sessions.__ghostel_emit_oschelper per shell; the five existing emitters route through it. Byte-output identical across bash/zsh/fish.set -g allow-passthrough onin tmux.conf (tmux 3.3+). Without it, tmux drops the wrapped sequence — same as before, no regression.~/.bashrc/~/.zshrc(auto-injection's env vars don't survive tmux pane spawns).Refs #195. Independent of the in-flight
feat/tmux(control-mode) work — that branch handlestmux -CC; this fix covers users on plain tmux.Notes from implementation
\\\\(not\\) in the single-quoted printf format because fish's single-quote consumes one level of\\→\before printf sees it.Test plan
make -j4 allgreen (39 + 96 + 190 tests, lint clean)od -c— wrapped form matches expected\ePtmux;\e\e]…\e\e\\\e\\with$TMUXset, bare OSC otherwiseghostel-test-shell-osc-tmux-wrapping(elisp suite) spawns each shell, asserts byte-exact output for both$TMUXstatesallow-passthrough on):cdshould updatedefault-directory;find-fileshould default to the shell's cwd