added auto-completion for change-wine

This commit is contained in:
Sergey Palcheh
2025-09-11 13:28:50 +06:00
parent bab49377a3
commit b98c6e5408
2 changed files with 35 additions and 1 deletions

View File

@@ -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)"} )