diff options
| author | xq114 <[email protected]> | 2023-01-16 13:03:16 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2023-01-16 13:03:16 +0800 |
| commit | eeed327070129470469f7d78028fe0e8caba1e2c (patch) | |
| tree | 427c7f84a6616bfdd3ccbd34558e0261d8869b4f /xmake/scripts | |
| parent | 130a8e4d62be37e6696c90015a70d6f6d0b225da (diff) | |
update profiles
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/profile-unix.sh | 19 | ||||
| -rw-r--r-- | xmake/scripts/profile-win.ps1 | 22 |
2 files changed, 39 insertions, 2 deletions
diff --git a/xmake/scripts/profile-unix.sh b/xmake/scripts/profile-unix.sh index 26d9d6a66..cd511b04f 100644 --- a/xmake/scripts/profile-unix.sh +++ b/xmake/scripts/profile-unix.sh @@ -7,6 +7,13 @@ if [[ "$SHELL" = */zsh ]]; then reply=( "${(ps:\n:)completions}" ) } compctl -f -S "" -K _xmake_zsh_complete xmake + # zsh parameter completion for xrepo + _xrepo_zsh_complete() + { + local completions=("$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.xrepo.complete 0 nospace "$words")") + reply=( "${(ps:\n:)completions}" ) + } + compctl -f -S "" -K _xrepo_zsh_complete xrepo elif [[ "$SHELL" = */bash ]]; then # bash parameter completion for xmake _xmake_bash_complete() @@ -20,6 +27,18 @@ elif [[ "$SHELL" = */bash ]]; then COMPREPLY=( $(compgen -W "$completions") ) } complete -o default -o nospace -F _xmake_bash_complete xmake + # bash parameter completion for xrepo + _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}")" + if [ $? -ne 0 ]; then + completions="" + fi + COMPREPLY=( $(compgen -W "$completions") ) + } + complete -o default -o nospace -F _xrepo_bash_complete xrepo fi # virtual environments for *nix shell function xrepo { diff --git a/xmake/scripts/profile-win.ps1 b/xmake/scripts/profile-win.ps1 index 493543040..f19c48233 100644 --- a/xmake/scripts/profile-win.ps1 +++ b/xmake/scripts/profile-win.ps1 @@ -7,8 +7,26 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock { } $oldenv = $env:XMAKE_SKIP_HISTORY $env:XMAKE_SKIP_HISTORY = 1 - xmake lua --root private.utils.complete "0" "nospace" "$complete" | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object { + $hasdesc = [bool] $_.psobject.Properties['description'] + $desc = $hasdesc ? " - $($_.description)" : "" + [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value) + } + $env:XMAKE_SKIP_HISTORY = $oldenv +} +# PowerShell parameter completion for xrepo +Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock { + param($commandName, $wordToComplete, $cursorPosition) + $complete = "$wordToComplete" + if (-not $commandName) { + $complete = $complete + " " + } + $oldenv = $env:XMAKE_SKIP_HISTORY + $env:XMAKE_SKIP_HISTORY = 1 + xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object { + $hasdesc = [bool] $_.psobject.Properties['description'] + $desc = $hasdesc ? " - $($_.description)" : "" + [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value) } $env:XMAKE_SKIP_HISTORY = $oldenv }
\ No newline at end of file |
