{"id":13501723,"url":"https://github.com/click-contrib/click-completion","last_synced_at":"2025-10-21T20:57:51.219Z","repository":{"id":11274581,"uuid":"64014436","full_name":"click-contrib/click-completion","owner":"click-contrib","description":"Add or enhance bash, fish, zsh and powershell completion in Click","archived":false,"fork":false,"pushed_at":"2024-04-15T06:57:47.000Z","size":71,"stargazers_count":284,"open_issues_count":14,"forks_count":32,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-24T03:31:24.111Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/click-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-23T12:05:25.000Z","updated_at":"2024-06-18T13:40:58.982Z","dependencies_parsed_at":"2024-04-15T08:13:29.499Z","dependency_job_id":null,"html_url":"https://github.com/click-contrib/click-completion","commit_stats":{"total_commits":65,"total_committers":17,"mean_commits":3.823529411764706,"dds":"0.41538461538461535","last_synced_commit":"a9b705d4f4df4579a96851b2b14b0c59765ef6ce"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/click-contrib%2Fclick-completion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/click-contrib%2Fclick-completion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/click-contrib%2Fclick-completion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/click-contrib%2Fclick-completion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/click-contrib","download_url":"https://codeload.github.com/click-contrib/click-completion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222481587,"owners_count":16991483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:01:47.551Z","updated_at":"2025-10-21T20:57:46.201Z","avatar_url":"https://github.com/click-contrib.png","language":"Python","readme":"# click-completion\nEnhanced completion for Click\n\n\u003e [!WARNING]\n\u003e This project is in maintenance mode only. No new features will be added.\n\nAdd automatic completion support for [fish], [Zsh], [Bash] and\n[PowerShell] to [Click].\n\nAll the supported shells are able to complete all the command line\narguments and options defined with click. In addition, fish and Zsh are\nalso displaying the options and commands help during the completion.\n\n[![asciicast](https://asciinema.org/a/74sjdBLPwkzq3BUVgyS7f63DO.png)](https://asciinema.org/a/74sjdBLPwkzq3BUVgyS7f63DO?speed=2\u0026loop=1\u0026autoplay=1)\n\n## Click 8 native completion\n\nEveryone using click 8.0 or later should use the native completion that was\nintroduced in this version.\n\nThis project is only for click before 8.0.\n\n## Activation\n\nIn order to activate the completion, you need to:\n\n* initialize the `click_completion` module;\n* inform your shell that completion is available for your script, and how.\n\n### `click_completion` initialization\n\n`click_completion` monkey-patches `click` in order to enhance the native\ncompletion capabilities. This is done very simply:\n\n    import click_completion\n    click_completion.init()\n\nOnce done, your click application is ready for completion.\n\n### Inform your shell\n\n`click_completion` has some functions to produce the code to be executed\nby the shell during the completion, and to permanently install this code\nin a place that is automatically loaded by the shell.\n\nThe key functions are:\n\n* `get_code`\n* `install`\n\nAn example of usage can be found in [examples/click-completion-command](examples/click-completion-command)\nand in [examples/click-completion-callback](examples/click-completion-callback)\n\n## Dependencies\n\n`click-completion` obviously depends on `click`. `Jinja2` is used to\n generate the shell specific code.\n\nAnd of course to make it useful, you'll need to use fish, Bash, Zsh or\nPowerShell.\n\n## Customizing completion\n\n### Application level\n\n`click_complete` has a `startswith` function that can be replaced by a\ncustom one in order to customize the completion. Some extra environment\nvariable to be used during the completion can be passed to `get_code`\nand `install`. An example is available in [examples/click-completion-command](examples/click-completion-command).\n\n### Parameter type level\n\nThe custom parameter type may reimplement the `complete` method in order\nto customize the completion result. The `complete` method takes the\ncurrent context and the incomplete argument to be completed. It can\nreturn either a list of argument value that match the incomplete\nargument, or a list of tuples `(arg, help)`. This last form is preferred\nbecause it allows to display the help during the completion for the\nshells that supports it.\n\nAn example can be found in the class `DocumentedChoice` in [click_completion/__init__.py](click_completion/__init__.py).\n\n\n## How it works\n\nAs click, the general way `click_completion` works is through a magic environment\nvariable called `_\u003cPROG_NAME\u003e_COMPLETE`, where `\u003cPROG_NAME\u003e` is your application\nexecutable name in uppercase with dashes replaced by underscores.\n\nIf your tool is called foo-bar, then the magic variable is called\n`_FOO_BAR_COMPLETE`. By exporting it with the `source` value it will spit out the\nactivation script which can be trivially activated.\n\nFor instance, to enable fish completion for your foo-bar script, this is what\nyou would need to put into your `~/.config/fish/completions/foo-bar.fish`\n\n    eval (env _FOO_BAR_COMPLETE=source-fish foo-bar)\n\nFrom this point onwards, your script will have fish completion enabled.\n\nThe above activation example will always invoke your application on startup.\nThis might be slowing down the shell activation time significantly if you have\nmany applications. Alternatively, you could also ship a file with the contents\nof that, which is what Git and other systems are doing.\n\nThis can be easily accomplished:\n\n    _FOO_BAR_COMPLETE=source-fish foo-bar \u003e ~/.config/fish/completions/foo-bar.fish\n\n\n## License\n\nLicensed under the MIT, see LICENSE.\n\n## Contributing\n\nContributions are all very welcome!\n\nThis may be in the form of bug reports, pull requests, …\n\nA few subjects need some attention currently:\n\n* documentation\n* tests\n* argument parsing\n\n\n[fish]: https://fishshell.com\n[Zsh]: http://www.zsh.org\n[Bash]: https://www.gnu.org/software/bash\n[PowerShell]: https://msdn.microsoft.com/en-us/powershell/mt173057.aspx\n[Click]: http://click.pocoo.org\n","funding_links":[],"categories":["Completions","Python"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclick-contrib%2Fclick-completion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclick-contrib%2Fclick-completion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclick-contrib%2Fclick-completion/lists"}