FS#50727 - [aws-cli] Shell completion files in wrong dir
Attached to Project:
Community Packages
Opened by Guillaume ALAUX (galaux) - Saturday, 10 September 2016, 13:08 GMT
Last edited by Jonathan Steel (jsteel) - Tuesday, 27 September 2016, 18:41 GMT
Opened by Guillaume ALAUX (galaux) - Saturday, 10 September 2016, 13:08 GMT
Last edited by Jonathan Steel (jsteel) - Tuesday, 27 September 2016, 18:41 GMT
|
Details
After installing `aws-cli` package, one does not have shell
completion because some files look misplaced:
- `usr/bin/aws_bash_completer` - `usr/bin/aws_completer` - `usr/bin/aws_zsh_completer.sh` These should not belong to a PATH dir. For ZSH this should be somewhere around `/usr/share/zsh/` I guess (not a ZSH nor Bash specialist). Also, package contains this Windows shell script that we could get rid of: `/usr/bin/aws.cmd`! |
This task depends upon
I'll work out where the ZSH one should go (though I believe ZSH can use the bash completion) and tidy up the files from /usr/bin. That was a default from upstream.
From a quick look I think the ZSH script is to enable bash-compatible completion in ZSH. Users may have sourced this as per AWS docs so I'm inclined to leave this one. I think the aws_completer file should also stay there, as the completion scripts require it to be in your PATH. I could patch but probably best to report this upstream.
By having a look at the comment in `/usr/bin/aws_zsh_completer.sh`, its whole `_bash_complete()` function is useless (is only useful for old ZSH). I guess `aws_zsh_completer.sh` could be removed as it currently serves no use. Anyone willing to use ZSH completion just needs to add the following to its `.zshrc` (as explained in the official doc [0]):
```
autoload -Uz bashcompinit
bashcompinit -i
complete -C aws_completer aws
```
[0] https://github.com/aws/aws-cli#command-completion
```
# % source /path/to/zsh_complete.sh
#
# Typically that would be called somewhere in your .zshrc.
#
# Note, the overwrite of _bash_complete() is to export COMP_LINE and COMP_POINT
# That is only required for zsh <= edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# https://github.com/zsh-users/zsh/commit/edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# zsh relases prior to that version do not export the required env variables!
```
The mentioned commit dates back from Jan 4, 2013. Our ZSH is way past it.
I think what is really interesting here is to understand the intention behind upstream providing `aws_zsh_completer.sh` which IMO is to show what one should have in his/her .zshrc to enable completion. And for our – recent – version of ZSH, this would just be the 3 remaining lines:
```
autoload -Uz bashcompinit
bashcompinit -i
complete -C aws_completer aws
```
Don't take me wrong: I am really discussing a technicality here ;). I just added these 3 lines in my .zshrc – waiting for a "proper ZSH auto completion" as mentioned in the same comment – and everything works like a charm so this file really does not bother me.