Commit dc753d0
fix(shell): auto-configure PowerShell on Windows when SHELL is not set (#898)
* Refactor PowerShell environment detection for auto-config
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.
* fix(shell): restrict PowerShell auto-detect to non-Windows
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>
* fix(shell): auto-detect PowerShell on Windows via SHELL absence
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>
* refactor(shell): rename is_powershell_environment to should_auto_configure_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>
* fix(shell): show "shell extension" not "& completions" for PowerShell 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>
* fix(tests): isolate PowerShell detection in test environment
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>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6c3dade commit dc753d0
File tree
6 files changed
+169
-24
lines changed- .claude-plugin/skills/worktrunk/reference
- docs/content
- src/commands
- tests
- common
- integration_tests
6 files changed
+169
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
295 | 327 | | |
296 | 328 | | |
297 | 329 | | |
298 | 330 | | |
299 | 331 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
304 | 342 | | |
305 | 343 | | |
306 | 344 | | |
| |||
328 | 366 | | |
329 | 367 | | |
330 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
331 | 377 | | |
332 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
333 | 384 | | |
334 | 385 | | |
335 | 386 | | |
336 | 387 | | |
337 | | - | |
| 388 | + | |
338 | 389 | | |
339 | 390 | | |
340 | 391 | | |
| |||
379 | 430 | | |
380 | 431 | | |
381 | 432 | | |
382 | | - | |
| 433 | + | |
383 | 434 | | |
384 | 435 | | |
385 | 436 | | |
| |||
398 | 449 | | |
399 | 450 | | |
400 | 451 | | |
401 | | - | |
| 452 | + | |
402 | 453 | | |
403 | 454 | | |
404 | 455 | | |
| |||
468 | 519 | | |
469 | 520 | | |
470 | 521 | | |
471 | | - | |
472 | | - | |
| 522 | + | |
| 523 | + | |
473 | 524 | | |
474 | 525 | | |
475 | 526 | | |
| |||
517 | 568 | | |
518 | 569 | | |
519 | 570 | | |
520 | | - | |
| 571 | + | |
521 | 572 | | |
522 | 573 | | |
523 | 574 | | |
| |||
544 | 595 | | |
545 | 596 | | |
546 | 597 | | |
547 | | - | |
| 598 | + | |
548 | 599 | | |
549 | 600 | | |
550 | | - | |
| 601 | + | |
551 | 602 | | |
552 | 603 | | |
553 | 604 | | |
| |||
614 | 665 | | |
615 | 666 | | |
616 | 667 | | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
| 668 | + | |
| 669 | + | |
621 | 670 | | |
| 671 | + | |
| 672 | + | |
622 | 673 | | |
623 | 674 | | |
624 | 675 | | |
| |||
882 | 933 | | |
883 | 934 | | |
884 | 935 | | |
885 | | - | |
| 936 | + | |
886 | 937 | | |
887 | | - | |
888 | | - | |
889 | 938 | | |
890 | 939 | | |
891 | 940 | | |
| |||
1122 | 1171 | | |
1123 | 1172 | | |
1124 | 1173 | | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
| 1174 | + | |
| 1175 | + | |
1129 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
1130 | 1179 | | |
1131 | 1180 | | |
1132 | 1181 | | |
| |||
1316 | 1365 | | |
1317 | 1366 | | |
1318 | 1367 | | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
1319 | 1371 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
693 | 698 | | |
694 | 699 | | |
695 | 700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1626 | 1626 | | |
1627 | 1627 | | |
1628 | 1628 | | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
0 commit comments