You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In PowerShell, cd desk* does not work as expected when using zoxide. Normally, PowerShell supports wildcard expansion in paths, but zoxide restricts this behavior. Instead of navigating to a matching directory (e.g., Desktop), it fails or does not expand the pattern.
Important
Upon reviewing the implementation, the issue seems to be caused by the use of the -LiteralPath parameter in the __zoxide_cd function. -LiteralPath prevents wildcard expansion, which explains why commands like cd desk* do not work.
Expected Behavior
PowerShell’s cd desk* should work similarly to its native behavior, where it matches a directory using wildcard expansion (e.g., resolving desk* to Desktop).
Actual Behavior
The command does not work as expected because zoxide uses Set-Location -LiteralPath, which prevents wildcard expansion.
Suspected Cause
The issue appears to be due to the __zoxide_cd function in the PowerShell integration:
Since -LiteralPath is used when $literal is true, it bypasses PowerShell's wildcard handling.
Suggested Fix
Consider modifying the function to allow wildcard expansion when applicable. Instead of -LiteralPath, using -Path should enable this functionality.
Or modify the function __zoxide_z, conditions to call __zoxide_cd with $literal = $false if the input contains wildcards.
This issue seems specific to PowerShell, as wildcard matching works differently in other shells (e.g., Bash).
If -LiteralPath is required for other use cases, an alternative could be to conditionally use -Path when the input contains wildcards.
The text was updated successfully, but these errors were encountered:
benzaria
changed the title
PowerShell: cd desk* Pattern Matching Doesn't Work Due to -LiteralPath
PowerShell: cd dir* Pattern Matching Doesn't Work Due to -LiteralPath
Feb 25, 2025
benzaria
added a commit
to benzaria/zoxide
that referenced
this issue
Feb 25, 2025
Description
In PowerShell,
cd desk*
does not work as expected when using zoxide. Normally, PowerShell supports wildcard expansion in paths, butzoxide
restricts this behavior. Instead of navigating to a matching directory (e.g.,Desktop
), it fails or does not expand the pattern.Important
Upon reviewing the implementation, the issue seems to be caused by the use of the
-LiteralPath
parameter in the__zoxide_cd
function.-LiteralPath
prevents wildcard expansion, which explains why commands likecd desk*
do not work.Expected Behavior
PowerShell’s
cd desk*
should work similarly to its native behavior, where it matches a directory using wildcard expansion (e.g., resolvingdesk*
toDesktop
).Actual Behavior
The command does not work as expected because
zoxide
usesSet-Location -LiteralPath
, which prevents wildcard expansion.Suspected Cause
The issue appears to be due to the
__zoxide_cd
function in the PowerShell integration:Since
-LiteralPath
is used when$literal
is true, it bypasses PowerShell's wildcard handling.Suggested Fix
Consider modifying the function to allow wildcard expansion when applicable. Instead of
-LiteralPath
, using-Path
should enable this functionality.Or modify the function
__zoxide_z
, conditions to call__zoxide_cd
with$literal = $false
if the input contains wildcards.Environment
Additional Notes
-LiteralPath
is required for other use cases, an alternative could be to conditionally use-Path
when the input contains wildcards.The text was updated successfully, but these errors were encountered: