Comments (24)
argcomplete now supports zsh directly (without the bashcompinit compatibility layer) in the develop branch.
The practical impact of this support is currently limited to emitting description strings in zsh, but by directly emitting completions to zsh instead of using the bash compatibility layer, we have unlocked the potential for using other, fancier zsh features as well.
Global completion is not supported yet (I am still looking into how to support it in zsh), so commands have to be individually registered with register-python-argcomplete.
I will be releasing this functionality in a new release shortly.
from argcomplete.
OK, I was able to activate global completion for zsh using compdef _python_argcomplete_global -P '*'
, so zsh is now fully and officially supported by argcomplete.
from argcomplete.
I don't really care about zsh, but it is within the scope of this package and it's certainly #2 on the list of shells to support.
Does bashcompinit
support complete -D
?
from argcomplete.
I do not have the foggiest - merely mentioned what I found on google as a starting point but I won't be much more use I am afraid. Had zsh support in aero before I yanked the custom implementation in favour of supporting argcomplete instead, for the greater good and all that. Would be nice to get it back but I won't be loosing any sleep over it just yet.
Anyone we can pass this ball to?
from argcomplete.
I tested bashcompinit
out of curiousity. It works.
$ autoload bashcompinit
$ bashcompinit
$ autoload compinit
$ compinit
$ eval "$(register-python-argcomplete docformatter)"
$ docformatter -<tab>
--help --recursive -h
--in-place --version -i
--no-blank --wrap-descriptions -r
--pre-summary-newline --wrap-summaries
from argcomplete.
Glad to hear that! If you want, you can write a test suite and add it to tests (please configure it to only run if zsh and bashcompinit are found).
from argcomplete.
While argcomplete does indeed run fine on zsh, zsh's auto-complete is far more advanced. argcomplete doesn't take advantage of any of this. Here are two example features that I'd love to see argcomplete handle:
- mini-documentation: zsh is capable of listing each possible argument with a mini documentation about it. When I type "git /tab/", I get:
add -- add paths to the index
am -- apply patches from a mailbox (cooler than applymbox)
annotate -- annotate file lines with commit info
- aliases: zsh is aware of aliases. For example, it can be told that '-h' is the same as '--help', and will display both of them on the same line, and won't show the --help if -h is already typed (and vice versa). In addition, for the mini-doc display, it will display them on the same line. For example, if I type "p4 /tab/", I get:
changelist change -- Create or edit a changelist description
They're shown together because "change" is an alias of the "changelist" subcommand.
Since argcomplete has all the necessary info to implement both these features, I'd strongly vote for doing this as a feature request. If I get around to doing it, I'll submit a patch. Meanwhile, thanks for argcomplete, it's awesome!
from argcomplete.
Sounds great, I'm not a big zsh user and don't have a lot of time for this, but I'd love to see this.
from argcomplete.
I found the commit that yanked out the custom autocomplete which worked for zsh as well, and got replaced by argcomplete. Aeronautics/aero@06de51e6c5d and this was the eval code Aeronautics/aero@5ec10de5057 which did the magic.
Along the lines of:
function _aero_completion {
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]" \\
COMP_CWORD=$(( cword-1 )) \\
AERO_AUTO_COMPLETE=1 $words[1] ) )
}
compctl -K _aero_completion aero
Does that shed any lights in the otherwise dark tunnel?
from argcomplete.
The current bash autocomplete works fine in zsh, since zsh can accept bash autocomplete scripts. However, this doesn't use the much more advanced features for autocomplete that zsh has. Taking advantage of these features would likely require a bunch of new code (i.e., it's not a simple fix, it requires some design and development).
from argcomplete.
Another example from aws-cli, which uses a wrapper similar to the one mentioned by @nickl- in Aero.
aws-cli approach to wrapping zsh: https://github.com/aws/aws-cli/blob/develop/bin/aws_zsh_completer.sh
$ source bin/aws_zsh_completer.sh
Related: tcsh on #49
from argcomplete.
@tony, thanks for the pointer to https://github.com/aws/aws-cli/blob/develop/bin/aws_zsh_completer.sh, there's some interesting/crazy code in there.
Does zsh have a convention for installing completion hooks globally or per user? And is anyone interested in finding out what should be done to make use of the advanced features that @redstreet is referring to?
from argcomplete.
As I mentioned earlier, the current bash autocomplete that argcomplete does works fine in zsh, since zsh can accept bash autocomplete scripts. The code at https://github.com/aws/aws-cli/blob/develop/bin/aws_zsh_completer.sh seems to help with getting this to work better, but doesn't use the advanced zsh autocompletion features themselves.
Here's an example of one of the features: showing brief descriptions next to parameters or subcommands:
http://joshparnham.com/2012/10/nanoc-plus-zsh-equals-awesomeness/
I've written small zsh autcomplete scripts, and I'd be happy to work on this, but won't have the time in the near future. If anyone is interested, here's a very basic tutorial to get you started:
http://askql.wordpress.com/2011/01/11/zsh-writing-own-completion/
from argcomplete.
Does argcomplete currently support global installation with zsh? I haven't managed to get it to work (while it works fine with zsh), and I don't think this is clearly specified in the docs.
from argcomplete.
I don't use zsh, so I don't have a clear idea of what level of compatibility its bash completion compatibility layer provides. From the zsh documentation, it seems like this should work:
autoload bashcompinit
bashcompinit
source argcomplete/bash_completion.d/python-argcomplete.sh
But cursory testing shows that it's not working.
from argcomplete.
Yes, that is what I tried. I understand fixing this is not a priority for you but can you please document this limitation?
from argcomplete.
In b38c1aa.
from argcomplete.
👍 for zsh support.
from argcomplete.
Pull requests are welcome. I would love to add it, but I don't use zsh on a daily basis and don't currently have the time to write this. Need a zsh expert to take a look.
from argcomplete.
FYI: I tested with zsh's bashcompinit
and it indeed seems to work fine.
As already stated, bash completion is overly simple (read: crap) and using zsh native completion would yield much better results... However, supporting multiple output formats in a code that was written with only one in mind sounds like more work than I'm willing to do. But a man can dream, right? :)
from argcomplete.
If completion doesn't work for you using bashcompinit
, note zsh-users/zsh@e2f793e which I had to apply to my system's bashcompinit
to get this to work.
from argcomplete.
Will global support work in zsh the same way it does in bash? I.e. not having to individually register files? The portion of the README addressing zsh only describes the individual file method.
from argcomplete.
When switching to zsh
and finding out that argcomplete
is not fully compatible (via this issue), I decided to try my hand at writing my own solution to this problem.
I have just released my first version of it, and thought to share for all of the people who'll reach this thread like I did.
The project is called pyzshcomplete
and can be found here.
Any feedback would be highly appreciated.
from argcomplete.
Released in v3.0.0.
from argcomplete.
Related Issues (20)
- Contributing guidelines for argcomplete? HOT 2
- How do I exclude files in the users directory from the tab completion? HOT 2
- Unable to get completion to work for NetExec HOT 2
- zsh: completion fails with script path starting with '~/' HOT 1
- 3.2.2: pytest is failing HOT 1
- Output of `argcomplete.warn` does not show HOT 4
- Generating lazy completion scripts for Bash/Zsh HOT 1
- Problem with os.get_terminal_size() and argcomplete HOT 2
- completion with a leading dash HOT 2
- Problems with trust path when packaging HOT 6
- No automatic testing on windows? HOT 2
- Python 3.13: Some tests fail when run with latest Python pre-release HOT 5
- Check recent argparse API changes for compatibility HOT 2
- completer falls back to Bash filename completion
- Python 3.12.3: Test suite fails HOT 1
- autocompletion is slow and stuck HOT 2
- Issue with File Path Autocompletion in Argparse Outside Virtual Environment HOT 4
- Inconsistent completion when using a custom validator between `fish` and `bash` HOT 1
- zsh global completion should not be "-default-" HOT 7
- Filesystem style double tab output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argcomplete.