config / .fgfs / _fgfs /
455a851 4 years ago
1 contributor
26 lines | 0.674kb
#compdef fgfs

local curcontext="$curcontext" state line expl args variant ret=1
typeset -A opt_args

# liste des appareils et leur description
local aircrafts=(
    ${(f)"$(find $FGADDON/Aircraft -maxdepth 2 -type f -name "*-set.xml" -exec grep '<description>' '{}' + \
    | sed -r 's|^.+/(.+)-set.xml:.+description>(.+)</description.*$|\1:\2|')"}
)

# options de FGFS et leur description
args=(
    ${(f)"$(sed -rn 's#^[^<]<(.+)-desc>(.+)</.+-desc>#--\1[\2]#p' $FGDIR/source/fgdata/Translations/default/options.xml)"}
)
args+=('*: :->aircraft')

_arguments -C $args && ret=0

case "$state" in
    (aircraft)
        _describe 'aircraft' aircrafts
    ;;
esac

return ret