{"id":17984430,"url":"https://github.com/adoyle-h/bash-completor","last_synced_at":"2025-03-25T20:32:04.708Z","repository":{"id":65960268,"uuid":"602928291","full_name":"adoyle-h/bash-completor","owner":"adoyle-h","description":"Creating a bash completion script in a declarative way.","archived":false,"fork":false,"pushed_at":"2024-11-02T05:33:01.000Z","size":36,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T17:51:31.570Z","etag":null,"topics":["bash","bash-completion","completion","completions","shell","shell-completion","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adoyle-h.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},"funding":{"patreon":"adoyle_h","liberapay":"adoyle","custom":["https://media.githubusercontent.com/media/adoyle-h/_imgs/master/sponsor.png"]}},"created_at":"2023-02-17T08:44:49.000Z","updated_at":"2024-12-05T15:37:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"76c2b781-5cd7-4036-bf89-dc03a8fd5d2e","html_url":"https://github.com/adoyle-h/bash-completor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fbash-completor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fbash-completor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fbash-completor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fbash-completor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adoyle-h","download_url":"https://codeload.github.com/adoyle-h/bash-completor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245540345,"owners_count":20632144,"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":["bash","bash-completion","completion","completions","shell","shell-completion","shell-script"],"created_at":"2024-10-29T18:21:21.807Z","updated_at":"2025-03-25T20:32:04.688Z","avatar_url":"https://github.com/adoyle-h.png","language":"Shell","readme":"# BashCompletor\n\nCreating a bash completion script in a declarative way.\n\n[English](./README.md) | [中文](./README.zh.md)\n\n## Feature\n\n- Declarative programming. You only need to know the most basic bash syntax.\n- Only `bash` and `sed` are needed on at compile time. Only `bash` is needed on at runtime. No other dependencies.\n- Support for command format looks like `\u003ccmd\u003e [options] [arguments]`.\n- Support for sub-commands, which looks like `\u003ccmd\u003e [cmd-options] \u003csubcmd\u003e [subcmd-options] [arguments]`.\n- Support for `-o`, `--option`, `--option \u003cvalue\u003e`, `--option=`, `+o`, `+option` format.\n- Support for completing file or directory paths.\n- Support for completing word lists.\n- Support for custom completion functions.\n- Friendly config typo checking and suggestions.\n\n## Requirements\n\n- For building script.\n  - Bash v4.3+\n  - cat, sed (GNU or BSD compatible)\n- For runtime. Bash v4.0+\n\n## Versioning\n\nRead [tags][] for versions.\nThe versions follow the rules of [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html).\n\n## Installation\n\nYou can install it by `curl` or `git`.\n\n### Curl\n\n```sh\nVERSION=v0.2.0\n\n# To download bash-completor\ncurl -LO \"https://github.com/adoyle-h/bash-completor/releases/download/$VERSION/bash-completor{,.md5}\"\n\n# Check files integrity\nmd5sum -c ./*.md5\n\n# Make it executable\nchmod +x ./bash-completor\n\n# Create symbol link or copy it to somewhere in your local $PATH\nsudo ln -s \"$PWD/bash-completor\" /usr/local/bin/bash-completor\n```\n\nThere is a completion script of bash-completor. You can install it if you need.\n\n```sh\n# To download the completion script of bash-completor\ncurl -LO \"https://github.com/adoyle-h/bash-completor/releases/download/$VERSION/bash-completor.completion.bash{,.md5}\"\n\n# Check files integrity\nmd5sum -c ./*.md5\n\n# Load the completion script of bash-completor in current shell\n. $PWD/bash-completor.completion.bash\n\n# Autoload it on startup\necho \". $PWD/bash-completor.completion.bash\" \u003e\u003e ~/.bashrc\n```\n\n### Git\n\n```sh\nVERSION=v0.2.0\n\n# Clone this repo\ngit clone --depth 1 --branch \"$VERSION\" https://github.com/adoyle-h/bash-completor.git\n\n# To build bash-completor\nmake build\n\n# Create symbol link or copy it to somewhere in your local $PATH\nsudo ln -s \"$PWD/dist/bash-completor\" /usr/local/bin/bash-completor\n\n# Load the completion script of bash-completor in current shell\n. $PWD/dist/bash-completor.completion.bash\n\n# Autoload the completion script of bash-completor if you need.\necho \". $PWD/dist/bash-completor.completion.bash\" \u003e\u003e ~/.bashrc\n```\n\n## Usage\n\nEnter `bash-completor` for help.\n\n1. Write a config file `completor.bash`.\n2. Run `bash-completor -c ./completor.bash` to generate completion script.\n\n## Configuration\n\n### [Syntax](./docs/syntax.md)\n\n### Examples\n\n- [./completor.bash](./completor.bash) It's a simple example. Run `make build` to build the completion script of bash-completor.\n- [zig.completor.bash](https://github.com/ziglang/shell-completions/blob/master/zig.completor.bash)\n- [nvim-shell-completions/nvim.completor.bash](https://github.com/adoyle-h/nvim-shell-completions/blob/master/nvim.completor.bash)\n- Other examples in [./example/](./example/)\n\n## The completion script\n\nThe generated completion script follows below code style. No worry about naming conflict.\nAnd it's easy to debug at runtime.\n\n- The main command completion function must be `_${cmd}_completions`\n- All subcmd completion functions must be named with prefix `_${cmd}_completions_${subcmd}`.\n- All other variables and functions must be named with prefix `_${cmd}_comp_`.\n- The variable of main command options must be `_${cmd}_comp_cmd_opts`.\n- The variable of subcmd options must be named with prefix `_${cmd}_comp_subcmd_opts_${subcmd}`.\n- All reply functions must be named with prefix `_${cmd}_comp_reply_`.\n- All customized reply functions must be named with prefix `_${cmd}_comp_reply_custom_`.\n\n## Suggestion, Bug Reporting, Contributing\n\n**Before opening new Issue/Discussion/PR and posting any comments**, please read [Contributing Guidelines](https://gcg.adoyle.me/CONTRIBUTING).\n\n### Test\n\nRun `make test` in shell.\n\n## Copyright and License\n\nCopyright 2023-2024 ADoyle (adoyle.h@gmail.com). Some Rights Reserved.\nThe project is licensed under the **Apache License Version 2.0**.\n\nSee the [LICENSE][] file for the specific language governing permissions and limitations under the License.\n\nSee the [NOTICE][] file distributed with this work for additional information regarding copyright ownership.\n\n## Other Projects\n\n- [lobash](https://github.com/adoyle-h/lobash): A modern, safe, powerful utility/library for Bash script development.\n- [one.bash](https://github.com/one-bash/one.bash): An elegant framework to manage commands, completions, dotfiles for bash players.\n- [Other shell projects](https://github.com/adoyle-h?tab=repositories\u0026q=\u0026type=source\u0026language=shell\u0026sort=stargazers) created by me.\n\n\n\u003c!-- links --\u003e\n\n[tags]: https://github.com/adoyle-h/bash-completor/tags\n[LICENSE]: ./LICENSE\n[NOTICE]: ./NOTICE\n","funding_links":["https://patreon.com/adoyle_h","https://liberapay.com/adoyle","https://media.githubusercontent.com/media/adoyle-h/_imgs/master/sponsor.png"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fbash-completor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadoyle-h%2Fbash-completor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fbash-completor/lists"}