Skip to content

fix: show suggestions for aliased bash-style flags#2

Merged
ericchansen merged 2 commits intomainfrom
fix/aliased-command-suggestions
Feb 24, 2026
Merged

fix: show suggestions for aliased bash-style flags#2
ericchansen merged 2 commits intomainfrom
fix/aliased-command-suggestions

Conversation

@ericchansen
Copy link
Copy Markdown
Owner

Summary

  • add reverse alias lookup so resolved cmdlets (for example, Remove-Item) map back to known aliases (for example, rm)
  • make prompt matching flag-aware so permutations like -fr, -rf, and -r -f are treated equivalently
  • add regression tests for reverse lookup and flag permutations

Validation

  • Invoke-Pester -Path .\tests -Output Detailed
  • 27 passed, 0 failed

ericchansen and others added 2 commits February 24, 2026 12:22
…ash-style flags

Two bugs prevented PSCommandHelper from showing suggestions when users
typed aliased commands with bash-style flags (e.g. rm -fr, ls -al):

1. Reverse alias lookup: When rm resolves to Remove-Item, the error's
   MyCommand.Name is 'Remove-Item', but the aliased map is keyed by
   'rm'. Added Get-Alias -Definition reverse lookup to find the alias.

2. Flag-aware matching: Bash flags can be combined in any order
   (-rf = -fr) or separated (-r -f). Replaced substring regex matching
   with flag-set comparison that normalizes and compares flag characters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- add cmdlet-based fallback map for aliased entries so suggestions still resolve when bash alias names (rm/ls/cp/mv) are not present on the host OS
- keep reverse alias lookup for environments where those aliases exist
- clear cmdlet fallback cache on unregister
- make reverse lookup tests platform-agnostic by validating alias-or-cmdlet fallback behavior

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ericchansen ericchansen merged commit 2fc62bd into main Feb 24, 2026
3 checks passed
@ericchansen ericchansen deleted the fix/aliased-command-suggestions branch February 24, 2026 18:34
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