diff options
| author | ruki <[email protected]> | 2023-03-03 00:59:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-03 00:59:06 +0800 |
| commit | 9662ca20a44e7a7639c9d8d42049f77be72253d7 (patch) | |
| tree | c22efcf44f56df8557f9e0147bd4add4464f63bc | |
| parent | 0d79efba9a282712c4dc1f8b2e63999a2d1b9236 (diff) | |
improve complete sh
| -rwxr-xr-x | xmake/scripts/completions/register-completions.bash | 25 | ||||
| -rwxr-xr-x | xmake/scripts/completions/register-completions.zsh | 16 | ||||
| -rwxr-xr-x | xmake/scripts/register-completions.sh | 46 |
3 files changed, 43 insertions, 44 deletions
diff --git a/xmake/scripts/completions/register-completions.bash b/xmake/scripts/completions/register-completions.bash new file mode 100755 index 000000000..d668c6ec1 --- /dev/null +++ b/xmake/scripts/completions/register-completions.bash @@ -0,0 +1,25 @@ +# bash parameter completion for xmake +_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}")" + if [ $? -ne 0 ]; then + completions="" + fi + 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 diff --git a/xmake/scripts/completions/register-completions.zsh b/xmake/scripts/completions/register-completions.zsh new file mode 100755 index 000000000..4a0bb9985 --- /dev/null +++ b/xmake/scripts/completions/register-completions.zsh @@ -0,0 +1,16 @@ +# zsh parameter completion for xmake +_xmake_zsh_complete() +{ + local completions=("$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.utils.complete 0 nospace "$words")") + 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 + diff --git a/xmake/scripts/register-completions.sh b/xmake/scripts/register-completions.sh index f3da05f10..48335bd89 100755 --- a/xmake/scripts/register-completions.sh +++ b/xmake/scripts/register-completions.sh @@ -1,48 +1,6 @@ - -# parameter completions for *nix shell - if [[ "$SHELL" = */zsh ]]; then - # zsh parameter completion for xmake - _xmake_zsh_complete() - { - local completions=("$(XMAKE_SKIP_HISTORY=1 XMAKE_ROOT=y xmake lua private.utils.complete 0 nospace "$words")") - 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 - + . "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.zsh" elif [[ "$SHELL" = */bash ]]; then - # bash parameter completion for xmake - _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}")" - if [ $? -ne 0 ]; then - completions="" - fi - 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 + . "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.bash" fi |
