diff options
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/completions/register-completions.bash | 4 | ||||
| -rw-r--r-- | xmake/scripts/completions/register-completions.fish | 2 | ||||
| -rw-r--r-- | xmake/scripts/completions/register-completions.zsh | 26 | ||||
| -rw-r--r-- | xmake/scripts/profile-win.ps1 | 10 |
4 files changed, 23 insertions, 19 deletions
diff --git a/xmake/scripts/completions/register-completions.bash b/xmake/scripts/completions/register-completions.bash index 4d02131f3..15c432f42 100644 --- a/xmake/scripts/completions/register-completions.bash +++ b/xmake/scripts/completions/register-completions.bash @@ -23,7 +23,7 @@ _xmake_bash_complete() { local word=${COMP_WORDS[COMP_CWORD]} local completions - completions="$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.utils.complete "${COMP_POINT}" "nospace-nokey" "${COMP_LINE}")" + completions="$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y XMAKE_COLORTERM=nocolor xmake lua private.utils.complete "${COMP_POINT}" "nospace-nokey" "${COMP_LINE}" 2>/dev/null)" if [ $? -ne 0 ]; then completions="" fi @@ -36,7 +36,7 @@ _xrepo_bash_complete() { local word=${COMP_WORDS[COMP_CWORD]} local completions - completions="$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.xrepo.complete "${COMP_POINT}" "nospace-nokey" "${COMP_LINE}")" + completions="$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y XMAKE_COLORTERM=nocolor xmake lua private.xrepo.complete "${COMP_POINT}" "nospace-nokey" "${COMP_LINE}" 2>/dev/null)" if [ $? -ne 0 ]; then completions="" fi diff --git a/xmake/scripts/completions/register-completions.fish b/xmake/scripts/completions/register-completions.fish index 05258bfd7..a48cfc1a4 100644 --- a/xmake/scripts/completions/register-completions.fish +++ b/xmake/scripts/completions/register-completions.fish @@ -27,7 +27,7 @@ function _xmake_fish_complete set -l token (commandline -ot) # Call XMake built-in completion to get available results - set -l result (MAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.utils.complete 0 nospace "$raw_cmd") + set -l result (XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y XMAKE_COLORTERM=nocolor xmake lua private.utils.complete 0 nospace "$raw_cmd" 2>/dev/null) if test (count $result) -lt 1 # When there are no available completions, the function ends immediately # Otherwise, the subsequent `contains` command will trigger an error diff --git a/xmake/scripts/completions/register-completions.zsh b/xmake/scripts/completions/register-completions.zsh index 2ddbe08e2..8817104ae 100644 --- a/xmake/scripts/completions/register-completions.zsh +++ b/xmake/scripts/completions/register-completions.zsh @@ -1,3 +1,5 @@ +#compdef xmake xrepo +# # A cross-platform build utility based on Lua # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,22 +21,18 @@ # # zsh parameter completion for xmake -_xmake_zsh_complete() -{ - local words - read -Ac words - local completions=("$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.utils.complete 0 nospace "$words")") - reply=( "${(ps:\n:)completions}" ) +_xmake_zsh_complete() { + local completions=("${(@f)$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y XMAKE_COLORTERM=nocolor xmake lua private.utils.complete 0 nospace "$words" 2>/dev/null)}") + compadd -Q -S '' -- ${completions[@]} } -compctl -f -S "" -K _xmake_zsh_complete xmake # zsh parameter completion for xrepo -_xrepo_zsh_complete() -{ - local words - read -Ac words - local completions=("$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.xrepo.complete 0 nospace "$words")") - reply=( "${(ps:\n:)completions}" ) +_xrepo_zsh_complete() { + local completions=("${(@f)$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y XMAKE_COLORTERM=nocolor xmake lua private.xrepo.complete 0 nospace "$words" 2>/dev/null)}") + compadd -Q -S '' -- ${completions[@]} } -compctl -f -S "" -K _xrepo_zsh_complete xrepo +case "$service" in + xmake) _xmake_zsh_complete ;; + xrepo) _xrepo_zsh_complete ;; +esac diff --git a/xmake/scripts/profile-win.ps1 b/xmake/scripts/profile-win.ps1 index 201f291cd..a708a8893 100644 --- a/xmake/scripts/profile-win.ps1 +++ b/xmake/scripts/profile-win.ps1 @@ -6,8 +6,10 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock { $complete = $complete + " " } $oldenv = $env:XMAKE_SKIP_HISTORY + $oldcolor = $env:XMAKE_COLORTERM $env:XMAKE_SKIP_HISTORY = 1 - $results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value + $env:XMAKE_COLORTERM = "nocolor" + $results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" 2>$null | ConvertFrom-Json | Sort-Object -Property value $results | ForEach-Object { $hasdesc = [bool] $_.psobject.Properties['description'] if ($hasdesc) { @@ -18,6 +20,7 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock { [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value) } $env:XMAKE_SKIP_HISTORY = $oldenv + $env:XMAKE_COLORTERM = $oldcolor } # PowerShell parameter completion for xrepo @@ -28,8 +31,10 @@ Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock { $complete = $complete + " " } $oldenv = $env:XMAKE_SKIP_HISTORY + $oldcolor = $env:XMAKE_COLORTERM $env:XMAKE_SKIP_HISTORY = 1 - $results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value + $env:XMAKE_COLORTERM = "nocolor" + $results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" 2>$null | ConvertFrom-Json | Sort-Object -Property value $results | ForEach-Object { $hasdesc = [bool] $_.psobject.Properties['description'] if ($hasdesc) { @@ -40,4 +45,5 @@ Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock { [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value) } $env:XMAKE_SKIP_HISTORY = $oldenv + $env:XMAKE_COLORTERM = $oldcolor }
\ No newline at end of file |
