{"id":13529908,"url":"https://github.com/kdabir/has","last_synced_at":"2025-05-15T01:06:43.350Z","repository":{"id":14317286,"uuid":"17026370","full_name":"kdabir/has","owner":"kdabir","description":"✅ checks presence of various command line tools and their versions on the path ","archived":false,"fork":false,"pushed_at":"2025-02-11T10:23:18.000Z","size":168,"stargazers_count":710,"open_issues_count":13,"forks_count":49,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-15T00:45:16.649Z","etag":null,"topics":["bash","check","cli","commands","hacktoberfest","hacktoberfest2021","linux","macos","shell","terminal"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/kdabir.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,"zenodo":null}},"created_at":"2014-02-20T16:09:25.000Z","updated_at":"2025-04-06T01:43:45.000Z","dependencies_parsed_at":"2022-08-07T08:00:05.795Z","dependency_job_id":"ef6ac99d-c584-44e0-848a-f6a59478c1fd","html_url":"https://github.com/kdabir/has","commit_stats":{"total_commits":112,"total_committers":19,"mean_commits":5.894736842105263,"dds":0.2857142857142857,"last_synced_commit":"7446f451dd3e717e6734be5a42fb4b0377e5942a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdabir%2Fhas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdabir%2Fhas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdabir%2Fhas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdabir%2Fhas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kdabir","download_url":"https://codeload.github.com/kdabir/has/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254041,"owners_count":22039792,"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","check","cli","commands","hacktoberfest","hacktoberfest2021","linux","macos","shell","terminal"],"created_at":"2024-08-01T07:00:40.656Z","updated_at":"2025-05-15T01:06:38.326Z","avatar_url":"https://github.com/kdabir.png","language":"Shell","readme":"# has\n\n`has` checks presence of various command line tools on the PATH and reports their installed version.\n\n[![Build Status](https://github.com/kdabir/has/actions/workflows/main.yml/badge.svg)](https://github.com/kdabir/has/actions/workflows/main.yml)\n[![Open Source Helpers](https://www.codetriage.com/kdabir/has/badges/users.svg)](https://www.codetriage.com/kdabir/has)\n\n[![demo](demo.svg)](demo.svg)\n\n## Quick Start 🚴\n\nJust [install](#installing) the `has` script, (there is no dependency apart from `bash` itself). From the command line, pass the list of commands you want to check as arguments to `has`, for example:\n\n```console\n$ has node npm java git gradle\n✔ node 8.2.1\n✔ npm 5.3.0\n✔ java 1.8.0\n✔ git 2.14.1\n✔ gradle 4.0.1\n```\n\nIf everything is good `has` exits with status code `0`. The exit status code reflects number of commands **not found** on your path.\n\n```console\n$ has node go javac\n✔ node 8.2.1\n✔ go 1.8.3\n✘ javac\n```\n\nAnd echo the status:\n\n```console\n$ echo $?\n1\n```\n\n## Use `has` in scripts\n\n`has` can be used in shell scripts to check presence of tool in very readable way\n\n```bash\nif has node\n    then echo you have what it takes 🎉\nfi\n```\n\n**Pro Tip**: the `has` in above command can be replaced with the entire curl command for to ensure portability of script → `if curl -sL https://git.io/_has | bash -s node then ...`\n\n\n## Installing 🚀\n\n`has` is a single bash script that does it all. You can [download](https://raw.githubusercontent.com/kdabir/has/master/has) the script and make it available on your `$PATH`. However, to make it even simpler, just follow *one* of these methods.\n\n### Homebrew (MacOS) 🍺\n\nJust run the following: \n\n```bash\nbrew install kdabir/tap/has\n```\n\n### Cloning the Repo\n\nJust execute the following command in a terminal: it clones `has` repo and installs it into your path.\n\n```bash\ngit clone https://github.com/kdabir/has.git \u0026\u0026 cd has \u0026\u0026 sudo make install\n```\n\nFor a non-root installation:\n\n```bash\ngit clone https://github.com/kdabir/has.git\ncd has\nmake PREFIX=$HOME/.local install\n```\n\nTo update just do a `git fetch` or `make update` followed by the appropriate `make install` command.\n\n### Downloading to a file\n\n```bash\ncurl -sL https://git.io/_has \u003e /usr/local/bin/has\n```\n\n```bash\ncurl -sL https://git.io/_has | sudo tee /usr/local/bin/has \u003e/dev/null\n```\n\nThese commands are safe to be called multiple times as well (to update `has`)\n\n### asdf users\n\n```\nasdf plugin add has https://github.com/sylvainmetayer/asdf-has\nasdf install has 1.4.0\n```\n\n### Running directly off the Internet\n\nIf you are lazy, you can run `has` directly off the Internet as well:\n\n```console\ncurl -sL https://git.io/_has | bash -s git node npm\n✔ git 2.17.1\n✔ node 11.11.0\n✔ npm 6.7.0\n```\n\n**ProTip**: if that's too much typing every time, setup an alias in your `.bashrc`/`.zshrc` file:\n\n```.bashrc\nalias has=\"curl -sL https://git.io/_has | bash -s\"\n```\n\nAnd use it\n\n```console\n$ has git\n✔ git 2.17.1\n$ type has\nhas is aliased to `curl -sL https://git.io/_has | bash -s'\n```\n\n## Command not understood by has?\n\nLet's say `$ has foobar` returns `foobar not understood`, because `has` may not have whitelisted `foobar`.\n\nIn such cases, pass `HAS_ALLOW_UNSAFE=y has foobar`. This should still check for existence of `foobar` and tries to detect version as well.\n\n\u003e the value must exactly be `y` for it to work.\n\n## The `.hasrc` file\n\n`has` looks for `.hasrc` file in the directory from where `has` command is issued. This file can contain commands that `has`\nwill check for. List one command per line. Lines starting with `#` are treated as comments.\n\nFollowing is example of `.hasrc` file:\n\n```hs\n# tools\ngit\ncurl\n\n# interpreters\nruby\nnode\n```\n\nWhen `has` is run in directory containing this file, it produces:\n\n```console\n$ has\n✔ git 2.19.1\n✔ curl 7.54.0\n✔ ruby 2.3.1\n✔ node 10.7.0\n```\n\nAlso, CLI arguments passed to `has` are additive to `.hasrc` file. For example, in the same dir, if the following command is fired,\n`has` checks for both commands passed from cli args and provided in `.hasrc` file.\n\n```bash\n$ has java\n✔ java 11.0.1\n✔ git 2.19.1\n✔ curl 7.54.0\n✔ ruby 2.3.1\n✔ node 10.7.0\n```\n\n**Pro Tip**: commit `.hasrc` file in root of your project. This can work as a quick check for confirming presence all command\nline tools required to build and run your project.\n\nOn machines that don't even have `has` installed, your project's `.hasrc` is honored by this command:\n\n`curl -sL https://git.io/_has | bash -s`\n\n\u003e take a look at [.hasrc](https://github.com/kdabir/has/blob/master/.hasrc) file for this repo.\n\n## Contributing\n\n1. Star the repo, tweet about it, spread the word\n2. Update the documentation (i.e. the README file)\n3. Adding support for more commands\n4. Adding more features to `has`\n\n## Adding more tools\n\nThe current list of supported packages can be viewed with `bash tests/packages_all.sh`\n\nIf the command you wish to include supports any of `-v`, `--version`, `-version`, `version`, `-V` then you can find \ncorresponding function which can be called to check presence and extract version. However, for many tools version\nextraction may not work and you will need to add custom parsing of command's output. The `has` script is commented\nto guide developers about what needs to be done to add more tools. \n\n`/tests/test_all_packages.bats` will test every package has supports. This includes newly added commands so please add new packages to\n - `alpine.Dockerfile` and `ubuntu.Dockerfile` to install the tool OR\n - `packages_alpine_skip.txt` and `packages_ubuntu_skip.txt` to exclude the package from the tests\n\n## Adding Features\n\nIf you are contributing a feature, please ensure to check current tests. Add test cases for your feature. Tests are\nexecuted using the excellent [bats](https://github.com/bats-core/bats-core) testing framework. Add tests and run `make test`\n\nRaise the PR and **make sure the tests pass** on [GitHub Actions](https://github.com/kdabir/has/actions).\n\n### ♥\n","funding_links":[],"categories":["Command-Line Productivity","Utilities","Shell","Tools","cli","\u003ca name=\"system\"\u003e\u003c/a\u003eSystem tools"],"sub_categories":["Reusable Things","Shell Utilities","Bash"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdabir%2Fhas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkdabir%2Fhas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdabir%2Fhas/lists"}