How should I use argcomplete in zsh?
Question:
I’m using argcomplete
to have Tab completion in Bash.
argcomplete
offers global completion for bash
, but doesn’t for zsh
.
I would like to create a file ~/.zsh_completion
, to contain the to be completed files. This file should generate autocompletion for those files when it’s sourced from ~/.zshrc
.
How do I do that?
Answers:
Alright there is a way to do it, but it’s not the way I really wanted it to be.
Anyway, here goes:
-
Install argcomplete
:
$ pip install argcomplete
-
Activate argcompolete
:
$ activate-global-python-argcomplete --user
-
Add this to ~/.zshrc
:
autoload bashcompinit
bashcompinit
source ~/.bash_completion.d/python-argcomplete.sh
eval "$(register-python-argcomplete /path/to/the/to/be/completed/file1)"
eval "$(register-python-argcomplete /path/to/the/to/be/completed/file2)"
eval "$(register-python-argcomplete /path/to/the/to/be/completed/file3)"
There’s probably a solution to read out the to be completed files from another file, but I don’t know how to do that.
Same as Exeleration-G but in your ~/.zshrc you only put
eval "$(cd path/to/script; register-python-argcomplete script.name)"
I’ve just released a new project by the name of pyzshcomplete
which can be found here.
It is meant to provide the same functionality as argcomplete
but for zsh
.
Argcomplete author here. I just released argcomplete v3, which supports zsh natively, without the bashcompinit
compatibility layer, and with full official support for completion descriptions and global completion (which gets installed by activate-global-python-argcomplete
into /usr/local/share/zsh/site-functions
by default, but that behavior is configurable). Please give it a try.
I’m using argcomplete
to have Tab completion in Bash.
argcomplete
offers global completion for bash
, but doesn’t for zsh
.
I would like to create a file ~/.zsh_completion
, to contain the to be completed files. This file should generate autocompletion for those files when it’s sourced from ~/.zshrc
.
How do I do that?
Alright there is a way to do it, but it’s not the way I really wanted it to be.
Anyway, here goes:
-
Install
argcomplete
:$ pip install argcomplete
-
Activate
argcompolete
:$ activate-global-python-argcomplete --user
-
Add this to
~/.zshrc
:autoload bashcompinit bashcompinit source ~/.bash_completion.d/python-argcomplete.sh eval "$(register-python-argcomplete /path/to/the/to/be/completed/file1)" eval "$(register-python-argcomplete /path/to/the/to/be/completed/file2)" eval "$(register-python-argcomplete /path/to/the/to/be/completed/file3)"
There’s probably a solution to read out the to be completed files from another file, but I don’t know how to do that.
Same as Exeleration-G but in your ~/.zshrc you only put
eval "$(cd path/to/script; register-python-argcomplete script.name)"
I’ve just released a new project by the name of pyzshcomplete
which can be found here.
It is meant to provide the same functionality as argcomplete
but for zsh
.
Argcomplete author here. I just released argcomplete v3, which supports zsh natively, without the bashcompinit
compatibility layer, and with full official support for completion descriptions and global completion (which gets installed by activate-global-python-argcomplete
into /usr/local/share/zsh/site-functions
by default, but that behavior is configurable). Please give it a try.