aboutsummaryrefslogtreecommitdiffstats
path: root/completion
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-07-03 05:08:22 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-07-03 05:08:22 -0400
commit1907d1037c2e5d98b8b55b563d7b0ce8cd4b408a (patch)
treed704c14acf3b6dd56a482dc30c730aea6eafa734 /completion
parentad1be39ef1dc25f2fe3a2f41a931d8e734cbeb76 (diff)
parent0d2edecb2be14c0ed92a33c7508358d648cd3d2f (diff)
Update upstream source from tag 'upstream/22'
Update to upstream version '22' with Debian dir 76cf8a8f0842846234438b4170eb5cf1a638e775
Diffstat (limited to 'completion')
-rw-r--r--completion/_archinstallscripts.zsh163
-rw-r--r--completion/arch-chroot.bash27
-rw-r--r--completion/genfstab.bash31
-rw-r--r--completion/pacstrap.bash38
4 files changed, 259 insertions, 0 deletions
diff --git a/completion/_archinstallscripts.zsh b/completion/_archinstallscripts.zsh
new file mode 100644
index 0000000..d2c8c7b
--- /dev/null
+++ b/completion/_archinstallscripts.zsh
@@ -0,0 +1,163 @@
+#compdef pacstrap genfstab arch-chroot
+
+_pacstrap_args=(
+ '-h[display help]'
+)
+
+_pacstrap_args_nonh=(
+ '(-h --help)-c[Use the package cache on the host, rather than the target]'
+ '(--help -h)-i[Avoid auto-confirmation of package selections]'
+)
+
+
+# builds command for invoking pacman in a _call_program command - extracts
+# relevant options already specified (config file, etc)
+# $cmd must be declared by calling function
+_pacman_get_command() {
+ # this is mostly nicked from _perforce
+ cmd=( "pacman" "2>/dev/null")
+ integer i
+ for (( i = 2; i < CURRENT - 1; i++ )); do
+ if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then
+ cmd+=( ${words[i,i+1]} )
+ fi
+ done
+}
+
+# provides completions for packages available from repositories
+# these can be specified as either 'package' or 'repository/package'
+_pacman_completions_all_packages() {
+ local -a cmd packages repositories packages_long
+ _pacman_get_command
+
+ if compset -P1 '*/*'; then
+ packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) )
+ typeset -U packages
+ _wanted repo_packages expl "repository/package" compadd ${(@)packages}
+ else
+ packages=( $(_call_program packages $cmd[@] -Sql) )
+ typeset -U packages
+ _wanted packages expl "packages" compadd - "${(@)packages}"
+
+ repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
+ typeset -U repositories
+ _wanted repo_packages expl "repository/package" compadd -S "/" $repositories
+ fi
+}
+
+_pacstrap_none(){
+ _arguments -s : \
+ "$_pacstrap_args[@]" \
+ "$_longopts[@]" \
+}
+
+_genfstab_args=(
+ '-h[display help]'
+)
+_genfstab_args_nonh=(
+ '(--help -h)-p[Avoid printing pseudofs mounts]'
+ '(-U --help -h)-L[Use labels for source identifiers]'
+ '(-L --help -h)-U[Use UUIDs for source identifiers]'
+)
+
+_arch_chroot_args=( '-h[display help]' )
+
+_longopts=( '--help[display help]' )
+
+_pacstrap(){
+ if [[ -z ${(M)words:#--help} && -z ${(M)words:#-h} ]]; then
+ case $words[CURRENT] in
+ -c*|-d*|-i*)
+ _arguments -s "$_pacstrap_args_nonh[@]"
+ ;;
+ -*)
+ _arguments -s : \
+ "$_pacstrap_args[@]" \
+ "$_pacstrap_args_nonh[@]" \
+ "$_longopts[@]"
+ ;;
+ --*)
+ _arguments -s : \
+ "$_longopts[@]"
+ ;;
+ *)
+ _arguments -s : \
+ "$_pacstrap_args[@]" \
+ "$_pacstrap_args_nonh[@]" \
+ "$_longopts[@]" \
+ ":*:_path_files -/" \
+ ":*:_pacman_completions_all_packages"
+ ;;
+ esac
+ else
+ return 1
+ fi
+}
+
+_genfstab(){
+ if [[ -z ${(M)words:#--help} && -z ${(M)words:#-*h} ]]; then
+ case $words[CURRENT] in
+ -p*|-L*|-U*)
+ _arguments -s : \
+ "$_genfstab_args_nonh[@]"
+ ;;
+ -*)
+ _arguments -s : \
+ "$_genfstab_args[@]" \
+ "$_genfstab_args_nonh[@]" \
+ "$_longopts[@]"
+ ;;
+ --*)
+ _arguments -s : \
+ "$_longopts[@]"
+ ;;
+ *)
+ _arguments \
+ "$_genfstab_args[@]" \
+ "$_genfstab_args_nonh[@]" \
+ "$_longopts[@]" \
+ ":*:_path_files -/"
+ ;;
+ esac
+ else
+ return 1
+ fi
+}
+
+_arch_chroot(){
+ if [[ -z ${(M)words:#--help} && -z ${(M)words:#-*h} ]]; then
+ case $words[CURRENT] in
+ -*)
+ _arguments -s : \
+ "$_arch_chroot_args[@]" \
+ "$_longopts[@]" \
+ ;;
+ --*)
+ _arguments -s : \
+ "$_longopts[@]"
+ ;;
+ *)
+ _arguments \
+ ':*:_path_files -/'
+ ;;
+ esac
+ else
+ return 1
+ fi
+}
+
+_install_scripts(){
+ case "$service" in
+ pacstrap)
+ _pacstrap "$@"
+ ;;
+ genfstab)
+ _genfstab "$@";;
+ arch-chroot)
+ _arch_chroot "$@";;
+ *)
+ _message "Error";;
+ esac
+}
+
+_install_scripts "$@"
diff --git a/completion/arch-chroot.bash b/completion/arch-chroot.bash
new file mode 100644
index 0000000..37fbf7c
--- /dev/null
+++ b/completion/arch-chroot.bash
@@ -0,0 +1,27 @@
+_arch_chroot() {
+ compopt +o dirnames
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="-u -h"
+
+ for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
+ if [[ -d ${i} ]]; then
+ return 0
+ fi
+ done
+
+ if [[ ${prev} = -u ]]; then
+ _usergroup -u
+ return 0
+ fi
+
+ if [[ ${cur} = -* ]]; then
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+ return 0
+ fi
+ compopt -o dirnames
+}
+
+complete -F _arch_chroot arch-chroot
diff --git a/completion/genfstab.bash b/completion/genfstab.bash
new file mode 100644
index 0000000..69506d9
--- /dev/null
+++ b/completion/genfstab.bash
@@ -0,0 +1,31 @@
+_genfstab() {
+ compopt -o dirnames
+ local cur prev words cword
+ _init_completion || return
+
+ local opts="-f -L -p -P -t -U -h"
+
+ case ${prev} in
+ -f)
+ return 0
+ ;;
+ -t)
+ COMPREPLY=($(compgen -W "LABEL UUID PARTLABEL PARTUUID" -- "${cur}"))
+ return 0
+ ;;
+ esac
+
+ if [[ ${cur} = -* ]]; then
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+ return 0
+ fi
+
+ for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
+ if [[ -d ${i} ]]; then
+ compopt +o dirnames
+ return 0
+ fi
+ done
+}
+
+complete -F _genfstab genfstab
diff --git a/completion/pacstrap.bash b/completion/pacstrap.bash
new file mode 100644
index 0000000..fb948f0
--- /dev/null
+++ b/completion/pacstrap.bash
@@ -0,0 +1,38 @@
+if ! declare -F _pacman_pkg > /dev/null; then
+ _completion_loader pacman
+fi
+
+_pacstrap() {
+ compopt +o dirnames +o default
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="-C -c -G -i -M -h"
+
+ for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
+ if [[ -d ${i} ]]; then
+ _pacman_pkg Slq
+ return 0
+ fi
+ done
+
+ case ${prev} in
+ -h)
+ return 0
+ ;;
+ -C)
+ compopt -o default
+ return 0
+ ;;
+ esac
+
+ if [[ ${cur} = -* ]]; then
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+ return 0
+ fi
+
+ compopt -o dirnames
+}
+
+complete -F _pacstrap pacstrap