forked from CastroFidel/winehelper
Merge branch 'VanoMJ-zsh_comp'
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
# Auto-completion for winhelper
|
# Auto-completion for winehelper
|
||||||
_winehelper_completions() {
|
_winehelper_completions() {
|
||||||
local cur prev opts
|
local cur prev opts
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
114
auto_completion/zsh_completion/_winehelper
Normal file
114
auto_completion/zsh_completion/_winehelper
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#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
|
Reference in New Issue
Block a user