Conversation
Introduce is_powershell_environment() function to detect PowerShell sessions via PSModulePath env var. Use this detection to auto-configure PowerShell when running `wt config shell install` from a PowerShell session, even if the profile doesn't exist yet (issue #885). On non-Windows, add PowerShell to the default shells list when detected. Rename explicit_shell parameter to allow_create for clarity, representing whether config files can be created for a shell.
On Windows, PSModulePath is set system-wide (even in Git Bash, cmd), making it unreliable for detecting PowerShell sessions. This caused false positives where `wt config shell install` would create PowerShell profiles when run from Git Bash. Changes: - Restrict is_powershell_environment() to non-Windows only - On Windows, require explicit `install powershell` to create profile - Add Windows-specific hint when PowerShell is skipped - Use var_os() instead of var() for robust env var checking On macOS/Linux, PowerShell Core must be explicitly installed, so PSModulePath being set is a reliable signal for auto-detection. Co-Authored-By: Claude <noreply@anthropic.com>
On Windows, detect Windows-native shells (cmd/PowerShell) by checking if the SHELL env var is NOT set. Git Bash, MSYS2, and Cygwin set SHELL, but cmd.exe and PowerShell don't. When detected, create both PowerShell profile files: - Documents/PowerShell/Microsoft.PowerShell_profile.ps1 (pwsh 7+) - Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 (5.1) This solves issue #885 where PowerShell users couldn't auto-configure shell integration because PSModulePath detection had false positives. Co-Authored-By: Claude <noreply@anthropic.com>
…igure_powershell The new name better reflects the function's purpose: it determines whether to auto-configure PowerShell profiles, not whether we're "in" PowerShell. Also adds an integration test for the WORKTRUNK_TEST_POWERSHELL_ENV override that verifies PowerShell profile creation works correctly. Co-Authored-By: Claude <noreply@anthropic.com>
… preview The preview output for `--dry-run` and `?` help was incorrectly showing "shell extension & completions" for PowerShell. Only Bash/Zsh have inline completions; Fish has separate files and PowerShell has no tab completion. This makes the preview consistent with the actual install output. Co-Authored-By: Claude <noreply@anthropic.com>
On CI environments: - Linux: PowerShell Core is installed, setting PSModulePath - Windows: Removing SHELL triggers the "SHELL not set" detection Both cause should_auto_configure_powershell() to return true in tests, adding PowerShell to the shell list and triggering the config hint. Fix by: 1. Removing PSModulePath to prevent Linux false positive 2. Setting WORKTRUNK_TEST_POWERSHELL_ENV=0 to disable detection entirely 3. Skip the PowerShell detection test on Windows (Documents folder can't be easily overridden in tests) Tests that need PowerShell detection should set the env var to "1". Co-Authored-By: Claude <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
SHELLenv var is absentFixes #885
Test plan
WORKTRUNK_TEST_POWERSHELL_ENVoverride--dry-runand?preview output🤖 Generated with Claude Code