diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-15 01:12:06 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-15 01:12:06 +0800 |
| commit | 10ed02b8541a80e60f7ad9f9fb51f8070d6be525 (patch) | |
| tree | bfc034d1ad0c2d5567a53ece074932040dfb8d43 /scripts/deploy | |
| parent | 72f80ea51f25256d0c463c2f3dc3d8670cfc4634 (diff) | |
Add completions system for shell autocompletion
Diffstat (limited to 'scripts/deploy')
| -rw-r--r-- | scripts/deploy/completions/bash.sh | 8 | ||||
| -rw-r--r-- | scripts/deploy/completions/fish.fish | 8 | ||||
| -rw-r--r-- | scripts/deploy/completions/powershell.ps1 | 8 | ||||
| -rw-r--r-- | scripts/deploy/completions/zsh.sh | 8 |
4 files changed, 16 insertions, 16 deletions
diff --git a/scripts/deploy/completions/bash.sh b/scripts/deploy/completions/bash.sh index 418105d..e1b2a31 100644 --- a/scripts/deploy/completions/bash.sh +++ b/scripts/deploy/completions/bash.sh @@ -40,13 +40,13 @@ _jvn_bash_completion() { fi local args=( - -f "$COMP_LINE" + -f "${COMP_LINE//-/^}" -C "$COMP_POINT" - -w "$cur" - -p "$prev" + -w "${cur//-/^}" + -p "${prev//-/^}" -c "${words[0]}" -i "$cword" - -a "${words[@]}" + -a "${words[@]//-/^}" ) local suggestions diff --git a/scripts/deploy/completions/fish.fish b/scripts/deploy/completions/fish.fish index 2904495..558b602 100644 --- a/scripts/deploy/completions/fish.fish +++ b/scripts/deploy/completions/fish.fish @@ -24,13 +24,13 @@ function __jvn_fish_complete end set -l args \ - -f "$buffer" \ + -f (string replace -a - ^ -- "$buffer") \ -C "$cursor" \ - -w "$current_word" \ - -p "$previous_word" \ + -w (string replace -a - ^ -- "$current_word") \ + -p (string replace -a - ^ -- "$previous_word") \ -c "$cmdline[1]" \ -i "$word_index" \ - -a $cmdline + -a (string replace -a - ^ -- "$cmdline") set -l output (jvn_comp $args 2>/dev/null) if test "$output" = "_file_" diff --git a/scripts/deploy/completions/powershell.ps1 b/scripts/deploy/completions/powershell.ps1 index 0c3cddc..ec91038 100644 --- a/scripts/deploy/completions/powershell.ps1 +++ b/scripts/deploy/completions/powershell.ps1 @@ -18,13 +18,13 @@ Register-ArgumentCompleter -CommandName jvn -ScriptBlock { } $args = @( - "-f", $line + "-f", ($line -replace '-', '^') "-C", $cursorPosition.ToString() - "-w", $wordToComplete - "-p", if ($words.Count -gt 1) { $words[-2] } else { "" } + "-w", ($wordToComplete -replace '-', '^') + "-p", (if ($words.Count -gt 1) { $words[-2] } else { "" }) -replace '-', '^' "-c", $commandName "-i", ($words.Count - 1).ToString() - "-a", $words + "-a", ($words | ForEach-Object { $_ -replace '-', '^' }) ) $suggestions = jvn_comp $args 2>$null diff --git a/scripts/deploy/completions/zsh.sh b/scripts/deploy/completions/zsh.sh index 2b2a96b..dd1ff38 100644 --- a/scripts/deploy/completions/zsh.sh +++ b/scripts/deploy/completions/zsh.sh @@ -15,13 +15,13 @@ _jvn_completion() { fi args=( - -f "$buffer" + -f "${buffer//-/^}" -C "$cursor" - -w "$current_word" - -p "$previous_word" + -w "${current_word//-/^}" + -p "${previous_word//-/^}" -c "$command_name" -i "$word_index" - -a "${words[@]}" + -a "${(@)words//-/^}" ) suggestions=$(jvn_comp "${args[@]}" 2>/dev/null) |
