Skip to content

Add Windows / PowerShell support via set_title.ps1#3

Open
BuzzRacing wants to merge 1 commit into
bluzername:mainfrom
BuzzRacing:windows-support
Open

Add Windows / PowerShell support via set_title.ps1#3
BuzzRacing wants to merge 1 commit into
bluzername:mainfrom
BuzzRacing:windows-support

Conversation

@BuzzRacing
Copy link
Copy Markdown

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.ps1 sidesteps this by calling [Console]::Title = ..., which wraps the Win32 SetConsoleTitle API 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 of set_title.sh. Same feature set: CLAUDE_TITLE_PREFIX env 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 a UserPromptSubmit hook 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 in temp_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.
  • No changes to install-and-test.sh, setup-zsh.sh, or uninstall.sh — those are Mac/Linux-specific and the Windows install is short enough to live in the README. I can add an install.ps1 in a follow-up if you'd like.

Testing

  • Manually verified [Console]::Title = "..." from a child PowerShell process updates the parent Windows Terminal tab title (the load-bearing assumption).
  • Manually verified set_title.ps1 "Test" and set_title.ps1 (no-arg, fail-safe) behaviors.
  • Verified the JSON-stdin path with a piped-payload simulation (real-world testing of this requires it being wired as a hook, which is a user-config decision outside the skill scope).

Test plan for reviewer:

  • On Windows: extract terminal-title.skill to ~/.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.
  • On Mac/Linux: existing bash scripts/set_title.sh "Test" flow unchanged, should still work as before.
  • Skill invocation: ask Claude Code to start a new task; it should run the appropriate script per OS based on the updated SKILL.md.

🤖 Generated with Claude Code

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>
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