source: tools/auto-complete.md @ f4fe7fd

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since f4fe7fd was c26b98c4, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Finally added some steps for auto-completion in zsh

  • Property mode set to 100644
File size: 1.3 KB
Line 
1Shell Auto Completion
2=====================
3
4tests/test.py
5-------------
6
7### Bash
8
9Short version: copy this into your .profile file:
10
11    _cfa_test() (
12        (case $3 in
13        (--continue|--debug|--install|--timout-with-gdb)
14            echo yes no;;
15        (--arch)
16            echo x86 x64;;
17        (-I|--include|-E|--exclude)
18            $1 --list-comp | tr ' ' '\n' | sed -e 's@/[^/]\+$@/@;t;d';;
19        (*)
20            $1 --list-comp;;
21        esac) | grep -Ewoe "$2[^[:space:]]*"
22    )
23    complete -C _cfa_test tests/test.py
24
25The long version includes reading the bash manual, check for the complete
26built-in and readline programmable completion for details on how these
27commands are used. You can copy-paste the results directily into your
28terminal to test them or put them in one of the initalization files so they
29are loaded at start-up.
30
31This particular script does not handle the comma seperated options.
32
33### Zsh
34
351 - Add the following somewhere:
36    #compdef test.py
37
38    _test_py() {
39        local -a options
40        options=$($words[1] --list-comp)
41        _alternative "files:filenames:($options)"
42    }
43
44    _test_py "$@"
45
462 - Add the path to that file to the "fpath" environment variable.
47
483 - In ~/.zshrc add
49    autoload -U compinit
50    compinit
51
52*How it works:* I don't know ;P
53
54
Note: See TracBrowser for help on using the repository browser.