~ubuntu-branches/debian/experimental/bash-completion/experimental

« back to all changes in this revision

Viewing changes to completions/dict

  • Committer: Package Import Robot
  • Author(s): David Paleino
  • Date: 2011-11-03 13:03:51 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20111103130351-mjans3w2ufbwwssf
Tags: 1:1.90-1
* bash-completion 2 preview: dynamic loading of completions
  - optionally fallback to generic file completion if _filedir
    returns nothing (Closes: #619014, LP: #533985)
  - various fixes (Closes: #622383)
  - apt: add 'download' to subcommands (Closes: #625234, LP: #720541)
  - aptitude: add 'versions' command (Closes: #604393)
  - dpkg-query: use the 'dpkg' completion (Closes: #642526)
  - lintian: remove --unpack-level (Closes: #623680)
  - rrdtool: complete filenames after commands (Closes: #577933)
  - provide profile.d hook for per user disabling of bash_completion
    (Closes: #593835)
  - mutt: support tildes when recursively sourcing muttrc files
    (Closes: #615134)
  - tar: improve tar *[cr]*f completions (Closes: #618734)
* More checks in update-bash-completion: avoid unnecessary
  sourcing of completion if symlink already exists
* Add message for users before they report a bug (debian/bug-presubj),
  I'm kind of fed-up with bugs caused by acroread.sh :/
* Removed patches merged upstream
* Drop trigger-based completion loading
* Standards-Version bump to 3.9.2, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# dict(1) completion
 
1
# dict(1) completion                                       -*- shell-script -*-
2
2
 
3
 
{ have dict || have rdict; } && {
4
3
_dictdata()
5
4
{
6
5
    dict $host $port $1 2>/dev/null | sed -ne \
9
8
 
10
9
_dict()
11
10
{
12
 
    local cur prev host port db dictfile
13
 
 
14
 
    COMPREPLY=()
15
 
    _get_comp_words_by_ref cur prev
16
 
    dictfile=/usr/share/dict/words
17
 
 
18
 
    for (( i=1; i < COMP_CWORD; i++ )); do
19
 
        case ${COMP_WORDS[i]} in
 
11
    local cur prev words cword
 
12
    _init_completion || return
 
13
 
 
14
    local host port db i
 
15
 
 
16
    for (( i=1; i < cword; i++ )); do
 
17
        case ${words[i]} in
20
18
            -h|--host)
21
 
                host=${COMP_WORDS[i+1]}
 
19
                host=${words[i+1]}
22
20
                [ -n "$host" ] && host="-h $host"
23
21
                i=$((++i))
24
22
                ;;
25
23
            -p|--port)
26
 
                port=${COMP_WORDS[i+1]}
 
24
                port=${words[i+1]}
27
25
                [ -n "$port" ] && port="-p $port"
28
26
                i=$((++i))
29
27
                ;;
30
28
            -d|--database)
31
 
                db=${COMP_WORDS[i+1]}
 
29
                db=${words[i+1]}
32
30
                [ -n "$db" ] && host="-d $db"
33
31
                i=$((++i))
34
32
                ;;
38
36
    done
39
37
 
40
38
    if [[ "$cur" = -* ]]; then
41
 
        COMPREPLY=( $( compgen -W '--host --port --database \
42
 
                   --match --strategy --config \
43
 
                   --nocorrect --dbs --strats \
44
 
                   --serverhelp --info --serverinfo \
45
 
                   --noauth --user --key --version \
46
 
                   --license --help --verbose --raw \
47
 
                   --pager --debug --html --pipesize --client' \
48
 
                   -- "$cur" ) )
 
39
        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
49
40
        return 0
50
41
    fi
51
42
 
62
53
            ;;
63
54
    esac
64
55
 
 
56
    local dictfile=/usr/share/dict/words
65
57
    [ -r $dictfile ] && \
66
58
        COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
67
 
}
 
59
} &&
68
60
complete -F _dict -o default dict rdict
69
 
}
70
61
 
71
 
# Local variables:
72
 
# mode: shell-script
73
 
# sh-basic-offset: 4
74
 
# sh-indent-comment: t
75
 
# indent-tabs-mode: nil
76
 
# End:
77
62
# ex: ts=4 sw=4 et filetype=sh