From 69c93dba3591d9404bc6b38d84aca731db84ad15 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 6 Jun 2019 12:36:44 +0800 Subject: improve tab complete on bash and zsh --- scripts/get.sh | 26 ++++++++++++-------------- scripts/register-completions.bash | 2 +- scripts/register-completions.zsh | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/get.sh b/scripts/get.sh index 164ec9c48..e89afea97 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -149,36 +149,34 @@ install_profile() echo "export PATH=$prefix/bin:\$PATH" > ~/.xmake/profile echo ' if [[ "$SHELL" = */zsh ]]; then - # zsh parameter completion for xmake _xmake_zsh_complete() { - local completions=("$(xmake lua private.utils.complete 0 "$words")") + local completions=("$(xmake lua private.utils.complete 0 nospace "$words")") - reply=( "${(ps:\n:)completions}" ) + reply=( "${(ps:\n:)completions}" ) } - compctl -K _xmake_zsh_complete xmake + compctl -f -S "" -K _xmake_zsh_complete xmake elif [[ "$SHELL" = */bash ]]; then - -# bash parameter completion for xmake + # bash parameter completion for xmake _xmake_bash_complete() { - local word=${COMP_WORDS[COMP_CWORD]} + local word=${COMP_WORDS[COMP_CWORD]} - local completions - completions="$(xmake lua private.utils.complete "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" - if [ $? -ne 0 ]; then - completions="" - fi + local completions + completions="$(xmake lua private.utils.complete "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" + if [ $? -ne 0 ]; then + completions="" + fi - COMPREPLY=( $(compgen -W "$completions" -- "$word") ) + COMPREPLY=( $(compgen -W "$completions" -- "$word") ) } - complete -f -F _xmake_bash_complete xmake + complete -o default -o nospace -F _xmake_bash_complete xmake fi ' >> ~/.xmake/profile diff --git a/scripts/register-completions.bash b/scripts/register-completions.bash index 11cadedf3..64655760d 100644 --- a/scripts/register-completions.bash +++ b/scripts/register-completions.bash @@ -13,4 +13,4 @@ _xmake_bash_complete() COMPREPLY=( $(compgen -W "$completions" -- "$word") ) } -complete -f -F _xmake_bash_complete xmake +complete -o default -o nospace -F _xmake_bash_complete xmake diff --git a/scripts/register-completions.zsh b/scripts/register-completions.zsh index ff019569f..509816e56 100644 --- a/scripts/register-completions.zsh +++ b/scripts/register-completions.zsh @@ -2,9 +2,9 @@ _xmake_zsh_complete() { - local completions=("$(xmake lua private.utils.complete 0 "$words")") + local completions=("$(xmake lua private.utils.complete 0 nospace "$words")") reply=( "${(ps:\n:)completions}" ) } -compctl -K _xmake_zsh_complete xmake +compctl -f -S "" -K _xmake_zsh_complete xmake -- cgit v1.3.1