You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add basic implementation of bash completion
* update cobra to 1.0.0 because of spf13/cobra#1048
* add support for zsh and fish, improved help messages
* add flag ´--no-descriptions´ to disable automatic command description (for shells that supports it)
* fix fish not supporting env variables with dash in the name
* fixed zsh completion not working
* revert "#compdef" patch
* add check on --no-description flag
add comments regarding "hacks"
change Replacer with ReplaceAll (for readability)
* add docs
* Apply suggestions from code review
fix typos and corrections
Co-authored-by: per1234 <[email protected]>
* forgot a space
* fix fish docs
* add test for completion
Co-authored-by: per1234 <[email protected]>
// Next 2 lines are Hack, fixed here https://github.com/spf13/cobra/pull/1122
72
+
s:=strings.ReplaceAll(buf.String(), "arduino-cli_comp", "arduino_cli_comp") //required because fish does not support env variables with "-" in the name
`arduino-cli` supports command-line completion (also known as *tab completion*) for basic commands.
2
+
Currently only `bash`, `zsh`, `fish` shells are supported
3
+
4
+
### Before you start
5
+
In order to generate the file required to make the completion work you have to [install](installation.md) Arduino CLI first.
6
+
7
+
### Generate the completion file
8
+
To generate the completion file you can use `arduino-cli completion [bash|zsh|fish] [--no-descriptions]`.
9
+
By default this command will print on the standard output (the shell window) the content of the completion file. To save to an actual file use the `>` redirect symbol.
10
+
11
+
### Bash
12
+
Use `arduino-cli completion bash > arduino-cli.sh` to generate the completion file.
13
+
At this point you can move that file in `/etc/bash_completion.d/` (root access is required) with `sudo mv arduino-cli.sh /etc/bash_completion.d/`.
14
+
15
+
A not recommended alternative is to source the completion file in `.bashrc`.
16
+
17
+
Remember to open a new shell to test the functionality
18
+
19
+
### Zsh
20
+
Use `arduino-cli completion zsh > _arduino-cli` to generate the completion file.
21
+
At this point you can place the file in a directory listed in your `fpath` if you have already created a directory to store your completion.
22
+
23
+
Or if you want you can create a directory, add it to your `fpath` and copy the file in it:
24
+
25
+
1.`mkdir ~/completion_zsh`
26
+
2. add `fpath=($HOME/completion_zsh $fpath)` at the beginning of your `.zshrc` file
27
+
3.`mv _arduino-cli ~/completion_zsh/`
28
+
29
+
Remember to open a new shell to test the functionality
30
+
31
+
*N.B.*
32
+
The Zsh completion is working with [Oh-My-Zsh](https://ohmyz.sh/) but not with [Prezto](https://github.com/sorin-ionescu/prezto) (the zsh completion system is working in a different way than classic zsh). But hopefully it will be fixed in the future
33
+
34
+
### Fish
35
+
Use `arduino-cli completion fish > arduino-cli.fish` to generate the completion file.
36
+
At this point you can place the file in `~/.config/fish/completions` as stated in the [official documentation](http://fishshell.com/docs/current/index.html#where-to-put-completions).
37
+
Remember to create the directory if it's not already there `mkdir -p ~/.config/fish/completions/` and then place the completion file in there with `mv arduino-cli.fish ~/.config/fish/completions/`
38
+
39
+
Remember to open a new shell to test the functionality
40
+
41
+
#### Disabling command and flag descriptions
42
+
By default fish completion has command and flag description enabled by default. If you want to disable this behaviour you can simply pass the `--no-descriptions` flag when calling `completion` command and the generated file will not have descriptions
0 commit comments