%PDF- %PDF-
Direktori : /usr/share/zsh/functions/Completion/Linux/ |
Current File : //usr/share/zsh/functions/Completion/Linux/_veeamconfig |
#compdef veeamconfig # # ZSH completion script # (c) Veeam Software Group GmbH # _veeamconfig() { IFS=$' ' lastArg="${words[-1]}" #echo "command=[${words[*]}]" # Call veeamconfig in *sh-completion mode and store result in 'completedArgs' completedArgs="$(VEEAM_BASH_COMPLETION=yes ${words[*]} 2>&1)" completedArgs_result=$? #echo "completedArgs=[${completedArgs}]" #echo "completedArgs_result=[${completedArgs_result}]" # If argument completing was failed, exit if [[ ${completedArgs_result} -gt 0 ]]; then #echo "err" return 0 fi # Prepare to return completed arguments as result IFS=$'\n' COMPREPLY=( $(echo "${completedArgs}") ) #echo "orig COMPREPLY=[${COMPREPLY[*]}]" # Fix completed results if command is not ends on ' '. if [[ ! -z $lastArg && ${#COMPREPLY[*]} > 0 ]]; then lastArg_lc="`echo \"${lastArg}\" | sed -e 's/\(.*\)/\L\1/'`" lastArg_lc="`echo \"${lastArg_lc}\" | sed -e 's/\\\//g'`" complArg_lc="`echo \"${COMPREPLY[1]}\" | sed -e 's/\(.*\)/\L\1/'`" complArg_lc="`echo \"${complArg_lc}\" | sed -e 's/\\\//g'`" #echo "COMPREPLY[1]=[${COMPREPLY[1]}]" #echo "lastArg=[${lastArg}]" #echo "complArg_lc=[${complArg_lc}]" #echo "lastArg_lc=[${lastArg_lc}]" if [[ "${complArg_lc}" != "${lastArg_lc}"* ]]; then #echo " reset COMPREPLY" COMPREPLY=("${lastArg}") fi fi #echo "final COMPREPLY=[${COMPREPLY[*]}]" complArgsLine=$(IFS=$' '; echo "${COMPREPLY[*]}") #echo "complArgsLine=[${complArgsLine}]" if [ -z $complArgsLine ]; then #echo "err" return 0 fi finalArgs="*: :(${complArgsLine})" #echo "finalArgs=[${finalArgs}]" # We need case insensitive completion zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' #zstyle ':completion:*:*veeam*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' _arguments -n "${finalArgs}" return 0 } _veeamconfig "$@"