Add Windows / PowerShell support via set_title.ps1#3
Open
BuzzRacing wants to merge 1 commit into
Open
Conversation
On Windows, Claude Code's Bash tool strips control bytes from subprocess stdout before display, so the bash version's printf '\033]0;...\007' approach never reaches the host terminal. Adds a parallel set_title.ps1 that calls [Console]::Title (Win32 SetConsoleTitle) on the inherited console, bypassing the stdout channel entirely. Feature parity with set_title.sh: CLAUDE_TITLE_PREFIX env var, cwd-name prefix, fail-safe on empty input. Also accepts JSON on stdin so the script can be wired as an optional UserPromptSubmit hook. SKILL.md updated to dispatch by OS. README adds Windows install steps, expanded compatibility matrix, Windows troubleshooting, and an explainer for why a second script is needed. terminal-title.skill (binary zip) is not modified — left for the maintainer to rebuild on release. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Adds Windows support to the terminal-title skill alongside the existing macOS/Linux bash implementation. The README currently lists "Windows native terminals (Command Prompt, PowerShell)" as a known limitation — this PR removes that limitation for Windows Terminal and the modern Windows console.
Why a second script
On Windows, the bash version's
printf '\033]0;...\007'approach does not work when Claude Code invokes the script through its Bash tool, even though Windows Terminal itself fully supports OSC 0 title sequences. The reason: Claude Code's Bash tool sanitizes control bytes from subprocess stdout before display, so the ESC byte never reaches the host terminal. I verified this empirically — the resulting tool output is the literal text]0;...with the ESC stripped.The new
scripts/set_title.ps1sidesteps this by calling[Console]::Title = ..., which wraps the Win32SetConsoleTitleAPI on the inherited console. Because the hook PowerShell subprocess inherits Claude Code's console, the title-set call hits the host terminal directly — no stdout channel involved, no sanitization possible.What's in the PR
scripts/set_title.ps1(new) — PowerShell mirror ofset_title.sh. Same feature set:CLAUDE_TITLE_PREFIXenv var, cwd-name prefix, fail-safe on empty input, 60-char cap, control-byte sanitization. Also accepts JSON on stdin so users can optionally wire it as aUserPromptSubmithook for prompt-based auto-titling (not required for the skill to work).SKILL.md— Implementation section now dispatches by OS. macOS/Linux → bash via Bash tool; Windows → PowerShell via PowerShell tool. Working-directory path style is suggested as the OS hint if Claude is unsure.README.md— Windows manual-install block, expanded compatibility matrix (Windows Terminal + PowerShell promoted to "Fully Tested"), new "Why a Second Script?" explainer, Windows troubleshooting section.What's not in the PR
terminal-title.skill(the binary zip) is untouched. The source-of-truth intemp_extract/has the new files; I left the zip rebuild to you on release so you can use whatever tooling you normally do and decide on the LICENSE/CHANGELOG/VERSION bump.install-and-test.sh,setup-zsh.sh, oruninstall.sh— those are Mac/Linux-specific and the Windows install is short enough to live in the README. I can add aninstall.ps1in a follow-up if you'd like.Testing
[Console]::Title = "..."from a child PowerShell process updates the parent Windows Terminal tab title (the load-bearing assumption).set_title.ps1 "Test"andset_title.ps1(no-arg, fail-safe) behaviors.Test plan for reviewer:
terminal-title.skillto~/.claude/skills/(after rebuilding with the new files), then& "$env:USERPROFILE\.claude\skills\terminal-title\scripts\set_title.ps1" "Test"— Windows Terminal tab title should change.bash scripts/set_title.sh "Test"flow unchanged, should still work as before.🤖 Generated with Claude Code