#/usr/bin/env bash _mageia4arm_completions() { local cur prev commands i PLATFORMS_PATH commands="--all --build-path --clean --log --config --target --target-version --mga-version --nonfree --size --tainted --compress --add-checksum --add-urpmimedia --chroot --create-chroot --create-image --help --install-basesystem --jump-chroot --prepare-chroot --sign --update-mirror --desktop --package " COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} DESKTOP_LIST="cinnamon cinnamon-minimal enlightenment enlightenment-minimal gnome gnome-minimal lxde lxde-minimal lxqt lxqt-minimal mate mate-minimal plasma5 plasma5-minimal sugar windowmaker xfce xfce-minimal fvwm2" MGA_VERSION_LIST="1 2 3 4 5 6 7 8 cauldron" if [ -e /usr/share/mageia4arm/platforms ]; then if [ -d /usr/share/mageia4arm/platforms ]; then PLATFORMS_PATH="/usr/share/mageia4arm/platforms" fi fi if [ -e "$(dirname $(realpath $0))/platforms" ]; then if [ -d "$(dirname $(realpath $0))/platforms" ]; then PLATFORMS_PATH="$(dirname $(realpath $0) | sed 's/ /\\ /g')/platforms" fi fi if [ -e ./platforms ]; then if [ -d ./platforms ]; then PLATFORMS_PATH="$(realpath ./platforms | sed 's/ /\\ /g')" fi fi if [ "x" != "${PLATFORMS_PATH:="x"}" ]; then BOARDS="$(find ./platforms/ -maxdepth 1 -type d | sed -e 's/^\.\/platforms\///' -e '/^$/d' )" fi #First, if command line empty, show all possible commands if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "${commands}" -- "$cur" ) ) else #then, removes already typed commands from suggestions for i in ${commands} ; do echo ${COMP_LINE} | grep -e "${i}" &>/dev/null if [ 0 -eq ${?} ]; then commands="$(echo ${commands} | sed -e "s/$i//" )" fi done prev=${COMP_WORDS[COMP_CWORD-1]} pprev=${COMP_WORDS[COMP_CWORD-2]} if [ ${pprev} == "--build-path" ]; then prev=jump elif [ ${pprev} == "--config" ]; then prev=jump elif [ ${pprev} == "--desktop" ]; then prev=jump elif [ ${pprev} == "--mga-version" ]; then prev=jump elif [ ${pprev} == "--package" ]; then prev=jump elif [ ${pprev} == "--size" ]; then prev=jump elif [ ${pprev} == "--target" ]; then prev=jump elif [ ${pprev} == "--target-version" ]; then prev=jump fi case $prev in --all|--clean|--nonfree|--tainted|--log|--compress|--add-checksum|--add-urpmimedia|--chroot|--create-chroot|--create-image|--help|--install-basesystem|--jump-chroot|--prepare-chroot|--sign|--update-mirror|jump) COMPREPLY=( $( compgen -W "${commands} " -- "$cur" ) ) ;; --mga-version) COMPREPLY=( $( compgen -W "${MGA_VERSION_LIST}" -- "$cur" ) ) ;; --desktop) COMPREPLY=( $( compgen -W "${DESKTOP_LIST}" -- "$cur" ) ) ;; --config) echo ${cur} | grep '/' &>/dev/null if [ 0 -eq ${?} ]; then # COMPREPLY=( $(compgen -W "$(for d in ${cur}* ${cur}*/*; do [[ -d "$d" ]] && echo $d/; done)" -- ${cur}) ) _filedir else COMPREPLY=( $( compgen -W "${BOARDS} " -- "$cur" ) ) fi ;; --build-path) _filedir -d ;; esac fi } complete -F _mageia4arm_completions mageia4arm complete -F _mageia4arm_completions ./create_arm_image.sh #Not implemented : # echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4" # echo -e "--create-chroot Create the chroot directory" # echo -e "--install-basesystem install base system" # echo -e "--add-urpmimedia add mirrors for urpmi" # echo -e "--chroot chroot to arm directory and launch packages installation" # echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"