#/usr/bin/env bash _mageia4arm_completions() { local cur prev commands i PLATFORMS_PATH commands="--all --build-path --clean --log --config --target --target-version --nonfree --size --tainted " COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} 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} == "--config" ]; then prev=jump elif [ ${pprev} == "--size" ]; then prev=jump elif [ ${pprev} == "--build-path" ]; 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|jump) COMPREPLY=( $( compgen -W "${commands} " -- "$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}"