{"id":13529685,"url":"https://github.com/dim-an/cod","last_synced_at":"2025-04-01T17:30:44.347Z","repository":{"id":38411529,"uuid":"231380500","full_name":"dim-an/cod","owner":"dim-an","description":"cod is a completion daemon for bash/fish/zsh","archived":false,"fork":false,"pushed_at":"2023-12-19T00:09:28.000Z","size":129,"stargazers_count":515,"open_issues_count":21,"forks_count":25,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-02T07:10:38.690Z","etag":null,"topics":["bash","completion","fish","shell","zsh"],"latest_commit_sha":null,"homepage":"","language":"Go","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/dim-an.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}},"created_at":"2020-01-02T12:46:25.000Z","updated_at":"2024-07-16T04:53:44.000Z","dependencies_parsed_at":"2023-02-13T02:46:00.327Z","dependency_job_id":"c99bf6c7-74de-42e3-a941-bbdefe2f9578","html_url":"https://github.com/dim-an/cod","commit_stats":{"total_commits":38,"total_committers":8,"mean_commits":4.75,"dds":"0.26315789473684215","last_synced_commit":"fdbe85afb8790821de1e48a3c8645ca0118ab4b9"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dim-an%2Fcod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dim-an%2Fcod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dim-an%2Fcod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dim-an%2Fcod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dim-an","download_url":"https://codeload.github.com/dim-an/cod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222748052,"owners_count":17031894,"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","completion","fish","shell","zsh"],"created_at":"2024-08-01T07:00:38.521Z","updated_at":"2024-11-02T16:30:56.964Z","avatar_url":"https://github.com/dim-an.png","language":"Go","readme":"![](https://img.shields.io/badge/GO-passing-green?style=for-the-badge\u0026logo=Go)\n\nCod is a completion daemon for ```bash```, ```fish```, and ```zsh```.\n\nIt detects usage of ```--help``` commands, parses their output, and generates\nauto-completions for your shell.\n\n![https://asciinema.org/a/h0SrrNvZVcqoSM4DNyEUrGtQh](https://github.com/TheBearodactyl/assets/blob/main/h0SrrNvZVcqoSM4DNyEUrGtQh.svg)\n\n# Install\n\n  You can either [download](https://github.com/dim-an/cod/releases) or [build](https://github.com/dim-an/cod/blob/master/README.org#Build) the ```cod``` binary\n  for your OS and put it into your ```$PATH```.\n\n  After that, you will need to edit your init script (e.g. ```~/.config/fish/config.fish```, ```~/.zshrc```, ```~/.bashrc```) and add a few lines for\n  the daemon to work correctly.\n\n### Bash\n   Add the following to your ```~/.bashrc```\n   ```bash\n   source \u003c(cod init $$ bash)\n   ```\n\n### Zsh\n   [Make sure](#compsys_init) completion system is initialized.\n\n   Add the following to your ```~/.zshrc```\n   ```zsh\n   source \u003c(cod init $$ zsh)\n   ```\n   Or, you can use a plugin manager like zinit:\n   ```zsh\n   zinit wait lucid for \\\n     dim-an/cod\n   ```\n\n#### \u003ca name=\"compsys_init\"\u003e\u003c/a\u003e Initializing zsh completion system\n\n  `cod` requires initialized completion system.\n  In many cases it is already the case (e.g. if you are using oh-my-zsh or similar framework).\n\n  You can check whether your completion system is already initilized by using `type compdef` command:\n  ```\n  # Completion system IS initialized\n  $ type compdef\n  compdef is a shell function from /usr/share/zsh/functions/Completion/compinit\n\n  # Completion system IS NOT initialized\n  $ type compdef\n  compdef not found\n  ```\n\n  If you found that you need to initialize completion system you can do this by:\n\n   - calling `compinit` function in your `.zshrc` before initializing `cod` itself, or\n   - executing `compinstall` command from your shell, it will modify `.zshrc` file for you.\n\n  Also check [zsh documentation](https://zsh.sourceforge.io/Doc/Release/Completion-System.html).\n\n\n### Fish\n   Add the following to ```~/.config/fish/config.fish```\n   ```fish\n   cod init $fish_pid fish | source\n   ```\n\n### Fig\n\nAs an alternative, you can also install ```cod``` with [Fig](https://fig.io/plugins/other/cod_dim-an) in ```bash```, ```zsh```, or ```fish``` with just one click.\n\n![https://fig.io/plugins/other/cod_dim-an](https://github.com/TheBearodactyl/assets/blob/main/install-with-fig.svg)\n\n### Supported shells and operating systems\n\n   - zsh\n   ```cod``` is known to work with latest version of ```zsh``` (tested: ```v5.5.1``` and\n   ```5.7.1```) on macOS and Linux.\n\n   - bash\n   ```cod``` also works with with latest version of ```bash``` (tested: ```4.4.20``` and\n   ```v5.0.11```) on Linux.\n\n     Note that default ```bash``` that is bundled with macOS is too old and ```cod```\n     doesn't support it.\n\n   - fish\n   ```cod``` works with latest version of ```fish``` (tested: ```v3.1.2```) on Linux\n   (I didn't have a chance to test it on macOS).\n\n\n# Building cod\n  It is recommended that you have at least [Go v1.19](https://golang.org/dl/) installed on your machine\n  ```bash\n  git clone https://github.com/dim-an/cod.git\n  cd cod\n  go build\n  ```\n\n  or\n\n  ```bash\n  go get -u github.com/dim-an/cod\n  ```\n\n# Overview\n  Cod checks each command you run in the shell. When cod detects usage of\n  ```--help``` flag it asks if you want it to learn this command. If you choose\n  to allow cod to learn this command cod will run command itself parse the\n  output and generate completions based on the ```--help``` output.\n\n## How cod detects help commands\n   Cod performs following checks to decide if command is help invocation:\n   1. checks if the ```--help``` flag is used\n   2. checks that command is simple i.e. doesn't contain any pipes, file\n     descriptor redirections, and other shell magic\n   3. checks that command exit code is 0.\n\n   If cod cannot automatically detect that your command is help invocation\n   you can use ```learn``` subcommand to learn this command anyway.\n\n## How cod runs help commands\n   Cod always uses absolute paths to run programs. (So it finds the binary in\n   ```$PATH``` or resolves relative path if required). Arguments other than\n   the binary path are left unchanged.\n\n   The current shell environment and current working directory will be\n   used.\n\n   If the program is successfully executed, cod will store:\n     - the absolute path to binary\n     - any used arguments\n     - the working directory\n     - environment variables\n   This info will be used to update command if required (check:\n   ```cod help update```).\n\n## How cod parses help output\n   ```cod``` has generic parser that works with most help pages and\n   recognizes flags (starting with ```-```), while not recognizing subcommands.\n\n   It also has a special parser tuned for [the python argparse library](https://docs.python.org/library/argparse.html)\n   that recognizes flags and subcommands.\n\n# Configuration\n  Cod will search for the default config file ```$XDG_CONFIG_HOME/cod/config.toml```.\n\n  The config file allows you to specify rules to either ignore or trust specified binaries\n\n  ```cod example-config``` prints an example configuration to stdout.\n\n  ```cod example-config --create``` writes an example config to the default directory of said config file (```$XDG_CONFIG_HOME/cod/config.toml```)\n\n# Data directories\n  ```cod``` uses ```$XDG_DATA_HOME/cod``` (default: ```~/.local/share/cod```) to store all\n  generated data files.\n","funding_links":[],"categories":["Completions","Go","Command-Line Productivity"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdim-an%2Fcod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdim-an%2Fcod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdim-an%2Fcod/lists"}