diff options
author | Guillaume Rousse <guillomovitch@mageia.org> | 2012-03-07 21:40:16 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mageia.org> | 2012-03-07 21:40:16 +0000 |
commit | 8c74062a4ddd213529f3f6e63775110d0b24f434 (patch) | |
tree | 2d2bf80489a210e959c6f7ae1e8bf0175005eac4 /urpmi.bash-completion | |
parent | c33f120889dd01c5b52f5d7d0fcf4af25b561ed2 (diff) | |
download | urpmi-8c74062a4ddd213529f3f6e63775110d0b24f434.tar urpmi-8c74062a4ddd213529f3f6e63775110d0b24f434.tar.gz urpmi-8c74062a4ddd213529f3f6e63775110d0b24f434.tar.bz2 urpmi-8c74062a4ddd213529f3f6e63775110d0b24f434.tar.xz urpmi-8c74062a4ddd213529f3f6e63775110d0b24f434.zip |
use 4 spaces as indentation step
Diffstat (limited to 'urpmi.bash-completion')
-rw-r--r-- | urpmi.bash-completion | 522 |
1 files changed, 261 insertions, 261 deletions
diff --git a/urpmi.bash-completion b/urpmi.bash-completion index 92afb816..63d922a2 100644 --- a/urpmi.bash-completion +++ b/urpmi.bash-completion @@ -7,130 +7,130 @@ common_options="-q --quiet -v --verbose --debug -h --help --urpmi-root --wait-lo # utility functions _urpmi_get_medias() { - medias=( $( urpmq --list-media $1 2>/dev/null | sed -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/ /\\ /g' ) ) + medias=( $( urpmq --list-media $1 2>/dev/null | sed -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/ /\\ /g' ) ) } _urpmi_medias() { - local medias IFS=$'\t\n' - # get medias list - _urpmi_get_medias all - # return matching ones - COMPREPLY=( $( compgen -W '${medias[@]}' -- $cur ) ) + local medias IFS=$'\t\n' + # get medias list + _urpmi_get_medias all + # return matching ones + COMPREPLY=( $( compgen -W '${medias[@]}' -- $cur ) ) } _urpmi_aliases() { - # return list of available aliases - COMPREPLY=( $( awk -F: '{print $1}' /etc/urpmi/parallel.cfg 2>/dev/null | grep "^${cur//\\\\/}" ) ) + # return list of available aliases + COMPREPLY=( $( awk -F: '{print $1}' /etc/urpmi/parallel.cfg 2>/dev/null | grep "^${cur//\\\\/}" ) ) } _urpmi_packages() { - local options medias - - # find media selection options - options="active" - for (( i=1; i < COMP_CWORD; i++ )); do - case "${COMP_WORDS[i]}" in - --@\(excludemedia|media\)) - options="$options ${COMP_WORDS[i]} ${COMP_WORDS[i+1]}" - i=$(($i+1)) - ;; - --update) - options="$options ${COMP_WORDS[i]}" - ;; - esac - done - - # get active media list - _urpmi_get_medias $options - - for media in $medias; do - COMPREPLY+=( $( compgen -W "$(grep ^$cur /var/lib/urpmi/names.$media 2>/dev/null)" ) ) - done + local options medias + + # find media selection options + options="active" + for (( i=1; i < COMP_CWORD; i++ )); do + case "${COMP_WORDS[i]}" in + --@\(excludemedia|media\)) + options="$options ${COMP_WORDS[i]} ${COMP_WORDS[i+1]}" + i=$(($i+1)) + ;; + --update) + options="$options ${COMP_WORDS[i]}" + ;; + esac + done + + # get active media list + _urpmi_get_medias $options + + for media in $medias; do + COMPREPLY+=( $( compgen -W "$(grep ^$cur /var/lib/urpmi/names.$media 2>/dev/null)" ) ) + done } # urpmi completion # _urpmi() { - local cur prev options - - COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` - - case "$prev" in - --media) - _urpmi_medias - return 0 - ;; - --excludemedia) - _urpmi_medias - return 0 - ;; - --sortmedia) - _urpmi_medias - return 0 - ;; - --searchmedia) - _urpmi_medias - return 0 - ;; - --parallel) - _urpmi_aliases - return 0 - ;; - --root|--urpmi-root) - _filedir -d - return 0 - ;; - esac - - if [[ "$cur" == -* ]]; then - # return list of available options - options="$common_options -a -p -P -y --update --media \ - --excludemedia --sortmedia --synthesis --auto \ - --auto-select --no-uninstall --split-level \ - --split-length --fuzzy --buildrequires --install-src --clean \ - --noclean --parallel --wget --prozilla --curl \ - --limit-rate --proxy --proxy-user --bug \ - --no-verify-rpm --no-install --test --excludepath \ - --excludedocs --searchmedia --ignoresize --ignorearch \ - --strict-arch --wget-options --curl-options \ - --prozilla-options --rsync-options --resume --retry \ - --skip --prefer --nolock --more-choices" - # add dangereous option for everything else as rurpmi - if [[ ${COMP_WORDS[0]} != *rurpmi ]]; then - options="$options --root --use-distrib --env \ - --auto-orphans --replacepkgs --justdb \ - --allow-nodeps --allow-force --no-suggests --force \ - --noscripts --auto-update --keep --nokeep --replacefiles\ - --verify-rpm" - for (( i=1; i < COMP_CWORD; i++ )); do - case ${COMP_WORDS[i]} in - ----auto-update) - options="$options --no-md5sum \ - --force-key" - ;; - esac - done - fi - COMPREPLY=( $( compgen -W "$options" -- $cur ) ) - else - if [[ ${COMP_WORDS[0]} == *rurpmi ]]; then - # return available packages only - _urpmi_packages - else - # return available packages (unless clearly a file) - # and rpm files - if [[ "$cur" != */* ]]; then - _urpmi_packages - fi - _filedir '@(rpm|spec)' - fi - fi + local cur prev options + + COMPREPLY=() + cur=`_get_cword` + prev=`_get_pword` + + case "$prev" in + --media) + _urpmi_medias + return 0 + ;; + --excludemedia) + _urpmi_medias + return 0 + ;; + --sortmedia) + _urpmi_medias + return 0 + ;; + --searchmedia) + _urpmi_medias + return 0 + ;; + --parallel) + _urpmi_aliases + return 0 + ;; + --root|--urpmi-root) + _filedir -d + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # return list of available options + options="$common_options -a -p -P -y --update --media \ + --excludemedia --sortmedia --synthesis --auto \ + --auto-select --no-uninstall --split-level \ + --split-length --fuzzy --buildrequires --install-src --clean \ + --noclean --parallel --wget --prozilla --curl \ + --limit-rate --proxy --proxy-user --bug \ + --no-verify-rpm --no-install --test --excludepath \ + --excludedocs --searchmedia --ignoresize --ignorearch \ + --strict-arch --wget-options --curl-options \ + --prozilla-options --rsync-options --resume --retry \ + --skip --prefer --nolock --more-choices" + # add dangereous option for everything else as rurpmi + if [[ ${COMP_WORDS[0]} != *rurpmi ]]; then + options="$options --root --use-distrib --env \ + --auto-orphans --replacepkgs --justdb \ + --allow-nodeps --allow-force --no-suggests --force \ + --noscripts --auto-update --keep --nokeep --replacefiles\ + --verify-rpm" + for (( i=1; i < COMP_CWORD; i++ )); do + case ${COMP_WORDS[i]} in + ----auto-update) + options="$options --no-md5sum \ + --force-key" + ;; + esac + done + fi + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + else + if [[ ${COMP_WORDS[0]} == *rurpmi ]]; then + # return available packages only + _urpmi_packages + else + # return available packages (unless clearly a file) + # and rpm files + if [[ "$cur" != */* ]]; then + _urpmi_packages + fi + _filedir '@(rpm|spec)' + fi + fi } complete -F _urpmi $filenames urpmi gurpmi rurpmi @@ -138,51 +138,51 @@ complete -F _urpmi $filenames urpmi gurpmi rurpmi # _urpmq() { - local cur prev - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - prev=${COMP_WORDS[COMP_CWORD-1]} - - case "$prev" in - --media) - _urpmi_medias - return 0 - ;; - --excludemedia) - _urpmi_medias - return 0 - ;; - --sortmedia) - _urpmi_medias - return 0 - ;; - --parallel) - _urpmi_nodes - return 0 - ;; - --list-media) - COMPREPLY=( $( compgen -W 'all update active' -- $cur)) - return 0 - ;; - esac - - if [[ "$cur" == -* ]]; then - # return list of available options - COMPREPLY=( $( compgen -W "$common_options -d -u -m -a -c -y -s -i -g -p \ - -r -f -l --update --media --excludemedia \ - --sortmedia --synthesis --auto-select --auto-orphans \ - --no-suggests --fuzzy --keep --nokeep \ - --list --list-url --list-media --list-nodes --list-aliases \ - --src --sources --provides --requires --obsoletes --suggests --summary --sourcerpm --force --parallel --wget --curl --prozilla \ - --changelog --conflicts --proxy --proxy-user --env --dump-config \ - --whatprovides --whatrequires --whatrequires-recursive \ - --skip --prefer \ - --use-distrib --searchmedia --ignorearch" -- $cur)) - else - # return rpm files (can't list available packages anymore) - _filedir rpm - fi + local cur prev + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --media) + _urpmi_medias + return 0 + ;; + --excludemedia) + _urpmi_medias + return 0 + ;; + --sortmedia) + _urpmi_medias + return 0 + ;; + --parallel) + _urpmi_nodes + return 0 + ;; + --list-media) + COMPREPLY=( $( compgen -W 'all update active' -- $cur)) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W "$common_options -d -u -m -a -c -y -s -i -g -p \ + -r -f -l --update --media --excludemedia \ + --sortmedia --synthesis --auto-select --auto-orphans \ + --no-suggests --fuzzy --keep --nokeep \ + --list --list-url --list-media --list-nodes --list-aliases \ + --src --sources --provides --requires --obsoletes --suggests --summary --sourcerpm --force --parallel --wget --curl --prozilla \ + --changelog --conflicts --proxy --proxy-user --env --dump-config \ + --whatprovides --whatrequires --whatrequires-recursive \ + --skip --prefer \ + --use-distrib --searchmedia --ignorearch" -- $cur)) + else + # return rpm files (can't list available packages anymore) + _filedir rpm + fi } complete -F _urpmq urpmq @@ -190,19 +190,19 @@ complete -F _urpmq urpmq # _urpme() { - local cur prev - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - - if [[ "$cur" == -* ]]; then - # return list of available options - COMPREPLY=( $( compgen -W "$common_options -a --auto --test \ - --auto-orphans --parallel --justdb --noscripts" -- $cur ) ) - else - # return list of available packages - _rpm_installed_packages - fi + local cur prev + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W "$common_options -a --auto --test \ + --auto-orphans --parallel --justdb --noscripts" -- $cur ) ) + else + # return list of available packages + _rpm_installed_packages + fi } complete -F _urpme urpme @@ -210,39 +210,39 @@ complete -F _urpme urpme # _urpmf() { - local cur prev - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - prev=${COMP_WORDS[COMP_CWORD-1]} - - case "$prev" in - --media) - _urpmi_medias - return 0 - ;; - --excludemedia) - _urpmi_medias - return 0 - ;; - --sortmedia) - _urpmi_medias - return 0 - ;; - esac - - if [[ "$cur" == -* ]]; then - # return list of available options - COMPREPLY=( $( compgen -W "$common_options -i -f -e -a -o -m --update \ - --media --excludemedia --sortmedia --synthesis --use-distrib \ - --uniq --name --group --license --size \ - --epoch --summary --description --sourcerpm --packager\ - --buildhost --url --provides --requires --suggests --files \ - --conflicts --obsoletes --env " -- $cur ) ) - else - # return available files - _filedir - fi + local cur prev + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + --media) + _urpmi_medias + return 0 + ;; + --excludemedia) + _urpmi_medias + return 0 + ;; + --sortmedia) + _urpmi_medias + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W "$common_options -i -f -e -a -o -m --update \ + --media --excludemedia --sortmedia --synthesis --use-distrib \ + --uniq --name --group --license --size \ + --epoch --summary --description --sourcerpm --packager\ + --buildhost --url --provides --requires --suggests --files \ + --conflicts --obsoletes --env " -- $cur ) ) + else + # return available files + _filedir + fi } complete -F _urpmf urpmf @@ -250,22 +250,22 @@ complete -F _urpmf urpmf # _urpmi_update() { - local cur - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - - if [[ "$cur" == -* ]]; then - # return list of available options - COMPREPLY=( $( compgen -W "$common_options -a -f --wget --prozilla \ - --curl --limit-rate --proxy --proxy-user --update \ - --ignore --no-ignore \ - --no-md5sum --force-key --norebuild" \ - -- $cur)) - else - # return list of available media - _urpmi_medias - fi + local cur + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W "$common_options -a -f --wget --prozilla \ + --curl --limit-rate --proxy --proxy-user --update \ + --ignore --no-ignore \ + --no-md5sum --force-key --norebuild" \ + -- $cur)) + else + # return list of available media + _urpmi_medias + fi } complete -F _urpmi_update urpmi.update @@ -273,42 +273,42 @@ complete -F _urpmi_update urpmi.update # _urpmi_addmedia() { - local cur i args - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - - if [[ "$cur" == -* ]]; then - # return list of available options - COMPREPLY=( $( compgen -W "$common_options -f --wget --curl --prozilla \ - --limit-rate --proxy --proxy-user --update --raw \ - --probe-synthesis --probe-hdlist --probe-rpms --no-probe --distrib \ - --env --version --arch --virtual --norebuild --nopubkey" -- $cur ) ) - else - # count number of mandatory args given sofar - args=$COMP_CWORD - for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == -* ]]; then - args=$(($args-1)) - fi - done - case $args in - 1) - # return list of available media - _urpmi_medias - ;; - 2) - # return list of available protocols - COMPREPLY=( $( compgen -W 'file:// http:// \ - ftp:// removable:// ssh:// \ - rsync://' -- $cur ) ) - ;; - 3) - # return word "with" - COMPREPLY=( 'with' ) - ;; - esac - fi + local cur i args + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ "$cur" == -* ]]; then + # return list of available options + COMPREPLY=( $( compgen -W "$common_options -f --wget --curl --prozilla \ + --limit-rate --proxy --proxy-user --update --raw \ + --probe-synthesis --probe-hdlist --probe-rpms --no-probe --distrib \ + --env --version --arch --virtual --norebuild --nopubkey" -- $cur ) ) + else + # count number of mandatory args given sofar + args=$COMP_CWORD + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -* ]]; then + args=$(($args-1)) + fi + done + case $args in + 1) + # return list of available media + _urpmi_medias + ;; + 2) + # return list of available protocols + COMPREPLY=( $( compgen -W 'file:// http:// \ + ftp:// removable:// ssh:// \ + rsync://' -- $cur ) ) + ;; + 3) + # return word "with" + COMPREPLY=( 'with' ) + ;; + esac + fi } complete -F _urpmi_addmedia urpmi.addmedia @@ -316,18 +316,18 @@ complete -F _urpmi_addmedia urpmi.addmedia # _urpmi_removemedia() { - local cur - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - - if [[ "$cur" == -* ]]; then - # if word begins with a dash, return list of available options - COMPREPLY=( $( compgen -W "$common_options -a -y" -- $cur ) ) - else - # elsewhere, return list of available media - _urpmi_medias - fi + local cur + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ "$cur" == -* ]]; then + # if word begins with a dash, return list of available options + COMPREPLY=( $( compgen -W "$common_options -a -y" -- $cur ) ) + else + # elsewhere, return list of available media + _urpmi_medias + fi } complete -F _urpmi_removemedia urpmi.removemedia |