Files
winehelper/auto_completion/zsh_completion/_winehelper
2025-07-02 19:31:32 +03:00

115 lines
3.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#compdef winehelper
# shellcheck disable=SC2034,SC2206
_winehelper() {
local -a opts wine_cmd scripts installed prefixes
opts=(
'--help[Вывести справку]'
'--version[Показать информацию о пакете и его версии]'
'--debug[Режим отладки]'
'install[Запустить скрипт установки программы]'
'installed[Список установленных программ]'
'-r[Запуск программы (отладка)]'
'-i[Запустить скрипт установки программы]'
'remove-all[Удалить WineHelper и все связанные данные]'
'--clear-pfx[Очистить префикс \[имя_префикса\]]'
'killall[Убить все процессы]'
'remove-prefix[Удалить префикс и все связанные данные]'
'backup-prefix[Создать резерную копию префикса]'
'restore-prefix[восстановить префикс из резервной копии "путь/до/whpack"]'
)
wine_cmd=(
winecfg
winereg
winefile
wineconsole
winetricks
desktop
regedit
explorer
cmd
'run[Запуск программы (отладка)]'
)
local context state line
_arguments -C \
'1:command:->cmds' \
'2:subcommand or argument:->args'
case $state in
cmds)
_values 'winehelper options' "${opts[@]}" "${wine_cmd[@]}"
;;
args)
case $words[2] in
--debug)
_values 'wine commands' "${wine_cmd[@]}"
;;
install|-i)
_get_list_for_install
;;
run|installed)
_get_installed_list
;;
remove-prefix|backup-prefix)
_get_prefixes
;;
restore-prefix)
_files
;;
*)
_values 'winehelper options' "${opts[@]}" "${wine_cmd[@]}"
;;
esac
;;
esac
}
_get_prefixes () {
prefixes=( ${(f)"$(ls -1 ~/.local/share/winehelper/prefixes 2>/dev/null)"} )
if ((! ${#prefixes[@]} == 0 )); then
_values 'prefixes' "${prefixes[@]}"
fi
}
_get_list_for_install () {
packages=(${(f)"$(winehelper install list 2>/dev/null |
awk -F ' - ' '
/^[^ ]+ - \("/ {next}
/^[[:space:]]*$/ {next}
/^Информация:/ {next}
/^[^ ]+ - / {
name=$1;
desc=$2;
gsub(/^[[:space:]]+|[[:space:]]+$/, "", name);
gsub(/^[[:space:]]*"?|"?[[:space:]]*$/, "", desc);
if (name && desc) print name ":" desc
}
')"})
packages+=(
scadoffice:"SCAD Office"
t-flex-cad17-applications:"Приложения для T-FLEX CAD 17"
t-flex-cad17-resources:"Обучающие материалы T-FLEX CAD 17"
)
_describe 'packages' packages
}
_get_installed_list () {
installed=(
${(f)"$(grep -h 'Exec=env' ~/.local/share/winehelper/*.desktop 2>/dev/null |
awk -F'/' '{print $NF}' |
awk -F'"' '{print $1}')"}
)
if ((! ${#installed[@]} == 0 )); then
_values 'installed apps' "${installed[@]}"
fi
}
compdef _winehelper winehelper