summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-03 00:59:06 +0800
committerruki <[email protected]>2023-03-03 00:59:06 +0800
commit9662ca20a44e7a7639c9d8d42049f77be72253d7 (patch)
treec22efcf44f56df8557f9e0147bd4add4464f63bc
parent0d79efba9a282712c4dc1f8b2e63999a2d1b9236 (diff)
improve complete sh
-rwxr-xr-xxmake/scripts/completions/register-completions.bash25
-rwxr-xr-xxmake/scripts/completions/register-completions.zsh16
-rwxr-xr-xxmake/scripts/register-completions.sh46
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