Last change
on this file since 89a8bab 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
|
Rev | Line | |
---|
[0f3d844] | 1 | Shell Auto Completion |
---|
| 2 | ===================== |
---|
| 3 | |
---|
| 4 | tests/test.py |
---|
| 5 | ------------- |
---|
| 6 | |
---|
| 7 | ### Bash |
---|
| 8 | |
---|
| 9 | Short 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 | |
---|
| 25 | The long version includes reading the bash manual, check for the complete |
---|
| 26 | built-in and readline programmable completion for details on how these |
---|
| 27 | commands are used. You can copy-paste the results directily into your |
---|
| 28 | terminal to test them or put them in one of the initalization files so they |
---|
| 29 | are loaded at start-up. |
---|
| 30 | |
---|
| 31 | This particular script does not handle the comma seperated options. |
---|
| 32 | |
---|
| 33 | ### Zsh |
---|
[c26b98c4] | 34 | |
---|
| 35 | 1 - 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 | |
---|
| 46 | 2 - Add the path to that file to the "fpath" environment variable. |
---|
| 47 | |
---|
| 48 | 3 - 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.