~elementary-os/ubuntu-package-imports/ppa-purge-bionic

« back to all changes in this revision

Viewing changes to debian/ppa-purge.bash-completion

  • Committer: RabbitBot
  • Date: 2018-02-05 14:08:45 UTC
  • Revision ID: rabbitbot@elementary.io-20180205140845-yp2s34d6zle1ga4e
Initial import, version 0.2.8+bzr63

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# /usr/share/bash-completion/completions/ppa-purge
 
2
# Debian ppa-purge(1) completion -*- shell-script -*-
 
3
 
 
4
_update_server(){
 
5
    local i
 
6
    for (( i=1; i < ${#words[@]}-1; i++)) ; do
 
7
        case "${words[i]}" in
 
8
            -s)
 
9
                SERVER=${words[i+1]}
 
10
                ;;
 
11
            *)
 
12
            ;;
 
13
        esac
 
14
    done
 
15
}
 
16
 
 
17
_update_owner(){
 
18
    local i
 
19
    for (( i=1; i < ${#words[@]}-1; i++)) ; do
 
20
        case "${words[i]}" in
 
21
            -o)
 
22
                OWNER=${words[i+1]}
 
23
                ;;
 
24
            *)
 
25
            ;;
 
26
        esac
 
27
    done
 
28
}
 
29
 
 
30
_ppa_names(){
 
31
    _update_server
 
32
    _update_owner
 
33
    grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/.*\/\(.*\)\/.*#\1#"
 
34
}
 
35
 
 
36
_ppa_host(){
 
37
    grep -hs "^deb\ .*tp\:\/\/.*\/.*\/.*" /etc/apt/sources.list.d/*.list | command sed "s#^deb.*\:\/\/\(.*\)\/.*\/.*/.*#\1#" | uniq
 
38
}
 
39
 
 
40
_ppa_owner(){
 
41
    _update_server
 
42
    grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | command sed "s#.*$SERVER\/\(.*\)\/.*\/.*#\1#"
 
43
}
 
44
 
 
45
_ppa_list(){
 
46
    _update_server
 
47
    _update_owner
 
48
    grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/\(.*\/.*\)\/.*#\1#" 
 
49
 
 
50
}
 
51
_ppa_purge(){
 
52
    OWNER=""
 
53
    SERVER="ppa.launchpad.net"
 
54
    local cur prev words cword opts
 
55
    _init_completion || return
 
56
 
 
57
    opts="-p -s -o -d -y -i -h"
 
58
 
 
59
    case "${prev}" in
 
60
        -p)
 
61
            COMPREPLY=( $( compgen -W "$(_ppa_names)" -- $cur ) )
 
62
            return 0
 
63
            ;;
 
64
        -s)
 
65
            COMPREPLY=( $( compgen -W "$(_ppa_host)" -- $cur ) )
 
66
            return 0
 
67
            ;;
 
68
        -o)
 
69
            COMPREPLY=( $( compgen -W "$(_ppa_owner)" -- $cur ) )
 
70
            return 0
 
71
            ;;
 
72
        *)
 
73
        ;;
 
74
    esac
 
75
    
 
76
    COMPREPLY=( $( compgen -W '${opts} $(_ppa_list)' -- "$cur" ) )
 
77
 
 
78
   return 0
 
79
} &&
 
80
complete -F _ppa_purge ppa-purge