From b98c6e5408251b1994ef0b8396506fe86e56d1b9 Mon Sep 17 00:00:00 2001 From: Sergey Palcheh Date: Thu, 11 Sep 2025 13:28:50 +0600 Subject: [PATCH] added auto-completion for change-wine --- auto_completion/bash_completion/winehelper | 16 +++++++++++++++- auto_completion/zsh_completion/_winehelper | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/auto_completion/bash_completion/winehelper b/auto_completion/bash_completion/winehelper index 2934046..e27bf5b 100644 --- a/auto_completion/bash_completion/winehelper +++ b/auto_completion/bash_completion/winehelper @@ -4,7 +4,7 @@ _winehelper_completions() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="--help --version --debug install installed install-dxvk install-vkd3d -r -i remove-all --clear-pfx killall remove-prefix backup-prefix restore-prefix create-prefix --changelog changelog" + opts="--help --version --debug install installed install-dxvk install-vkd3d -r -i remove-all --clear-pfx killall remove-prefix backup-prefix restore-prefix create-prefix --changelog changelog change-wine" wine_cmd="winecfg winereg winefile wineconsole winetricks desktop regedit explorer cmd run" case "${prev}" in @@ -34,6 +34,20 @@ _winehelper_completions() { restore-prefix) return 0 ;; + install-dxvk|install-vkd3d) + local versions=$(winehelper "${prev}" list 2>/dev/null | grep ' - ' | sed 's/ - //') + COMPREPLY=( $(compgen -W "${versions} none list" -- "${cur}") ) + return 0 + ;; + change-wine) + local wine_versions=$(awk ' + /^#+\s*(WINE|WINE_LG|PROTON_LG|PROTON_STEAM)\s*#*$/ { in_group=1 } + /^#+/ { if (! ($0 ~ /^#+\s*(WINE|WINE_LG|PROTON_LG|PROTON_STEAM)\s*#*$/)) in_group=0 } + /^[a-f0-9]{64}/ && in_group { sub(/\.tar\.xz$/, "", $2); print $2 } + ' /usr/share/winehelper/sha256sum.list 2>/dev/null) + COMPREPLY=( $(compgen -W "system ${wine_versions}" -- "${cur}") ) + return 0 + ;; *) ;; esac diff --git a/auto_completion/zsh_completion/_winehelper b/auto_completion/zsh_completion/_winehelper index ac9aded..41a49df 100644 --- a/auto_completion/zsh_completion/_winehelper +++ b/auto_completion/zsh_completion/_winehelper @@ -20,6 +20,7 @@ _winehelper() { 'remove-prefix[Удалить префикс и все связанные данные]' 'backup-prefix[Создать резерную копию префикса]' 'restore-prefix[восстановить префикс из резервной копии "путь/до/whpack"]' + 'change-wine[Изменить версию Wine/Proton для префикса]' ) wine_cmd=( @@ -69,6 +70,9 @@ _winehelper() { install-vkd3d) _get_component_versions 'install-vkd3d' ;; + change-wine) + _get_wine_versions + ;; *) _values 'winehelper options' "${opts[@]}" "${wine_cmd[@]}" ;; @@ -87,6 +91,22 @@ _get_component_versions () { _values 'versions' "${versions[@]}" } +_get_wine_versions () { + local -a versions + local sha256_file="/usr/share/winehelper/sha256sum.list" + + if [[ -f "$sha256_file" ]]; then + versions=( ${(f)"$(awk ' + /^#+\s*(WINE|WINE_LG|PROTON_LG|PROTON_STEAM)\s*#*$/ { in_group=1 } + /^#+/ { if (! ($0 ~ /^#+\s*(WINE|WINE_LG|PROTON_LG|PROTON_STEAM)\s*#*$/)) in_group=0 } + /^[a-f0-9]{64}/ && in_group { sub(/\.tar\.xz$/, "", $2); print $2 } + ' "$sha256_file" 2>/dev/null)"} ) + fi + + versions+=(system) + _values 'wine/proton versions' "${versions[@]}" +} + _get_prefixes () { prefixes=( ${(f)"$(ls -1 ~/.local/share/winehelper/prefixes 2>/dev/null)"} )