source: project/wiki/bash completion @ 36409

Last change on this file since 36409 was 31126, checked in by Mario Domenech Goulart, 6 years ago

Properly capitalize CHICKEN on the wiki directory (only first level).

I used the following shell script to change things:

while IFS= read -d $'\0' -r file ; do

sed -i 's/Chicken/CHICKEN/g' "$file"

done < <(find wiki -maxdepth 1 -type f -print0 )

Some files have been manually reverted after that, since some
substitutions don't apply:

  • friedly-chicken (repl banner)
  • survey2011 (Chicken in URI paths)
  • chickenista-guide (Chickenista)

I hope the link canonicalization thing will be on my side.

File size: 2.4 KB
Line 
1== bash completion for chicken tools
2
3The [[http://packages.debian.org/bash|Debian bash package]] features support for
4command line completion through the file {{/etc/bash_completion}}. This page of
5the chicken wiki provides a file to add completion for the chicken tools in bash.
6
7Currently, only {{chicken-setup}} is supported. Hopefully csi and csc will follow.
8
9CHICKEN 4 is currently not supported.
10
11=== Use
12
13Copy the following code in a file named {{chicken}} in {{/etc/bash_completion.d}}.
14Alternatively, source it after {{/etc/bash_completion}} (which is sourced from
15{{~/.bashrc}} or elsewhere).
16
17* {{chicken-setup <tab>}} completes for {{*.egg}} files.
18* {{chicken-setup -<tab>}} completes for options.
19
20<enscript highlight=bash>
21# chicken-setup command line completion for bash.
22#
23# version 0.2 -- 2007.01.13 -- vo minh thu
24#  - chicken-setup <tab> completes for *.egg files.
25# version 0.1 -- 2007.01.13 -- vo minh thu
26
27_chicken_setup()
28{
29    local cur prev frst opts
30    COMPREPLY=()
31    cur=${COMP_WORDS[COMP_CWORD]}
32    prev=${COMP_WORDS[COMP_CWORD-1]}
33    frst=${COMP_WORDS[1]}
34
35    opts='-help -version -repository -program-path -host \
36          -uninstall -list -run -script -eval -verbose \
37          -keep -csc-option -dont-ask -no-install -docindex \
38          -check -test -ls -fetch-tree -tree -svn -revision \
39          -local -destdir'
40
41    paroptions=${opts}
42
43    # the following options take zero or one argument
44    case "${prev}" in
45    '-repository' | '-program-path' | '-local' | '-destdir' )
46        COMPREPLY=( $(compgen -A directory ${cur}) )
47        return 0;;
48    '-host' )
49        COMPREPLY=( $(compgen -A hostname ${cur}) )
50        return 0;;
51    '-run' | '-script' | '-tree' )
52        COMPREPLY=( $(compgen -A file ${cur}) )
53        return 0;;
54    '-uninstall' | '-ls' )
55        local exts=$( chicken-setup -list | awk '{ print $1 }' )
56        COMPREPLY=( $(compgen -W "${exts}" -- ${cur}) )
57        return 0;;
58    esac
59
60    # the following options take zero or more arguments
61    case "${frst}" in
62    '-list' | '-test' )
63        local exts=$( chicken-setup -list | awk '{ print $1 }' )
64        COMPREPLY=( $(compgen -W "${exts}" -- ${cur}) )
65        return 0;;
66    esac
67
68    case ${cur} in
69    -* )
70        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
71        return 0;;
72    * )
73        COMPREPLY=($(compgen -f -X "egg" -- ${cur}))
74    esac
75
76}
77[ "$have" ] && complete -F _chicken_setup chicken-setup
78</enscript>
Note: See TracBrowser for help on using the repository browser.