Compare commits

...

4 Commits

Author SHA1 Message Date
Tobi 22e10ca220
Merge af1308e94f into 194f8e31e4 2025-10-05 19:09:44 +01:00
Ajeet D'Souza 194f8e31e4
Update README.md 2025-10-03 02:59:45 +05:30
Ajeet D'Souza eb7b08fed3
Update README.md 2025-09-30 18:34:43 +05:30
twobiers af1308e94f
Add PowerShell ArgumentCompleter 2025-05-13 16:20:46 +02:00
2 changed files with 48 additions and 2 deletions

View File

@ -12,12 +12,12 @@
<sup>Special thanks to:</sup>
<!-- markdownlint-disable-next-line MD013 -->
<div><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></div>
<div><a href="https://go.warp.dev/zoxide"><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></a></div>
<div><sup><b>Warp, built for coding with multiple AI agents.</b></sup></div>
<div><sup>Available for macOS, Linux, and Windows.</sup></div>
<div><sup>
Visit
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=zoxide_20231001"><u>warp.dev</u></a>
<a href="https://go.warp.dev/zoxide"><u>warp.dev</u></a>
to learn more.
</sup></div>

View File

@ -144,6 +144,52 @@ function global:__zoxide_zi {
Set-Alias -Name {{cmd}} -Value __zoxide_z -Option AllScope -Scope Global -Force
Set-Alias -Name {{cmd}}i -Value __zoxide_zi -Option AllScope -Scope Global -Force
filter __zoxide_escapeStringWithSpecialChars {
$_ -replace '\s|#|@|\$|;|,|''|\{|\}|\(|\)|"|`|\||<|>|&','`$&'
}
Register-ArgumentCompleter -Native -CommandName "{{cmd}}" -ScriptBlock {
param(
$WordToComplete,
$CommandAst,
$CursorPosition
)
# Get the current command line and convert into a string
$Command = $CommandAst.CommandElements
$Command = "$Command"
# The user could have moved the cursor backwards on the command-line.
# We only show completions when the cursor is at the end of the line
if ($Command.Length -gt $CursorPosition) {
return
}
$Program,$Arguments = $Command.Split(" ",2)
# If we don't have any parameter, just use the default completion (Which is Set-Location)
if([string]::IsNullOrEmpty($Arguments)) {
return
}
$QueryArgs = $Arguments.Split(" ")
# If the last parameter is complete (there is a space following it)
if ($WordToComplete -eq "" -And ( -Not $IsEqualFlag )) {
# Normally, we would invoke the interactive query. Unfortunally it is not possible to invoke an
# interactive command in a powershell argument completer. Therefore, we just return in that case to the
# default completion strategy.
# zoxide query -i -- @QueryArgs
return
} else {
$result = zoxide query --exclude "$(__zoxide_pwd)" -l -- @QueryArgs
}
$result | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($($_ | __zoxide_escapeStringWithSpecialChars), "$($_)", 'ParameterValue', "$($_)")
}
}
{%- when None %}
{{ not_configured }}