Skip to content

PowerShell hotkey integration for Windows#1

Merged
jarvan1 merged 2 commits into
mainfrom
feat/powershell-hotkey
Jul 5, 2026
Merged

PowerShell hotkey integration for Windows#1
jarvan1 merged 2 commits into
mainfrom
feat/powershell-hotkey

Conversation

@jarvan1

@jarvan1 jarvan1 commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Windows users had no Ctrl-X Ctrl-W hotkey: aiss init only emitted zsh/bash/fish snippets, and the default Windows shell is PowerShell. This adds a PowerShell integration and fixes a picker bug that made it hang on native Windows.

Changes

PowerShell integration

  • shell/aiss.ps1 — PSReadLine key handler bound to Ctrl-X Ctrl-W (override with $env:AISS_KEYBIND_PWSH). Captures stdout and deliberately leaves stderr alone, since that's where the picker draws.
  • aiss init powershell (alias pwsh) emits the embedded snippet.
  • --print --pwsh → new resumePlan.PowerShell() emitting Push-Location … ; try { & … } finally { Pop-Location }. PowerShell has no ( cd && ) subshell and escapes ' by doubling it, so the existing POSIX Shell() output can't be reused.

Picker fix (the reason the hotkey appeared dead)

  • The picker only acquired a terminal via /dev/tty, which doesn't exist on native Windows. It fell back to stderr for output but left input as the inherited os.Stdin. When the pwsh handler runs aiss with stdout captured to a pipe, that stdin carries no key events → the picker hangs with no way to select.
  • Terminal acquisition is now a platform helper: /dev/tty on POSIX (console_other.go), CONIN$/CONOUT$ on Windows (console_windows.go) — the same console-device approach fzf uses.

Testing

  • go build ./... && go vet ./... && go test ./... all pass.
  • Added TestPlanResumePowerShell and TestPwshQuoteEscapesQuotes.
  • Verified against real Windows PowerShell 5.1 (PSReadLine 2.0.0): handler registers as Ctrl+x,Ctrl+w → aiss, and the emitted Push-Location … Pop-Location command parses, executes, and restores the caller's directory even for a path containing a space and an embedded quote.
  • Confirmed Go opens CONIN$/CONOUT$ on an attached console.

POSIX behavior is unchanged — the Windows console code is behind a //go:build windows tag.

🤖 Generated with Claude Code

xuxinming and others added 2 commits July 3, 2026 21:01
The default shell on Windows is PowerShell, but `aiss init` only emitted
zsh/bash/fish snippets, so Windows users had no Ctrl-X Ctrl-W hotkey.

- shell/aiss.ps1: PSReadLine key handler (Ctrl-X Ctrl-W), override via
  $env:AISS_KEYBIND_PWSH. Captures stdout, leaves stderr alone so the
  picker stays visible.
- aiss init powershell (alias pwsh): emit the embedded snippet.
- --print --pwsh + resumePlan.PowerShell(): emit Push-Location / try /
  Pop-Location, since PowerShell has no `( cd && )` subshell and doubles
  single quotes rather than using '\''.
- tests for PowerShell() and pwshQuote(); README + goreleaser caveat.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The picker only acquired a terminal via /dev/tty, which doesn't exist on
native Windows. It fell back to stderr for output but left input as the
inherited os.Stdin — and when the pwsh handler runs us with stdout
captured to a pipe, that stdin carries no key events, so the picker hung
with no way to make a selection.

Split terminal acquisition into a platform helper: /dev/tty on POSIX,
CONIN$/CONOUT$ on Windows (the same console-device trick fzf uses).
Both input and output now go to the real console.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jarvan1
jarvan1 merged commit 404e620 into main Jul 5, 2026
1 check passed
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