Skip to content

feat: add shell completions for bash and zsh - #93

Merged
kdabir merged 1 commit into
kdabir:masterfrom
njg7194:add-shell-completions
Sep 5, 2026
Merged

kdabir merged 1 commit into
kdabir:masterfrom
njg7194:add-shell-completions

Conversation

@njg7194

@njg7194 njg7194 commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds shell completion support for both Bash and Zsh.

Changes

  • Add Bash completion script (completions/has.bash)
  • Add Zsh completion script (completions/_has)
  • Update Makefile with install-completions and uninstall-completions targets
  • Update README with installation instructions for completions

Usage

After installation, users will get tab-completion for:

  • Options (-q, -h, --help, -v, --version, --color-*)
  • Command names available on the system

Closes #65

- Add bash completion script (completions/has.bash)
- Add zsh completion script (completions/_has)
- Update Makefile with install-completions and uninstall-completions targets
- Update README with shell completions installation instructions

Closes kdabir#65
@goto-dev-null

Copy link
Copy Markdown
Contributor

Love this!

Can createa a separate PR if need be but here's a port of what you did for fish!

completions/has.fish

# Fish completion script for 'has' - https://github.com/kdabir/has
# A simple utility to check the presence of command line tools

# Disable file completions
complete -c has -f

# Options
complete -c has -s q -d 'Silent mode'
complete -c has -s h -l help -d 'Display this help text and quit'
complete -c has -s v -l version -d 'Show version number and quit'
complete -c has -l color-auto -d 'Enable color output automatically (default)'
complete -c has -l color-never -d 'Disable color output'
complete -c has -l color-always -d 'Always enable color output'

# Complete arguments with available commands on the system
complete -c has -f -a '(complete -C (commandline -ct))'

then here are the needed changes to the Makefile

--- Makefile
+++ Makefile
@@ -26,6 +26,7 @@
 # Completion directories
 BASH_COMPLETION_DIR := $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 ZSH_COMPLETION_DIR := $(DESTDIR)$(PREFIX)/share/zsh/site-functions
+FISH_COMPLETION_DIR := $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d

 # install 'has' in specified directory
 install : has
@@ -37,8 +38,10 @@
 install-completions:
 	mkdir -v -p $(BASH_COMPLETION_DIR) && \
 	mkdir -v -p $(ZSH_COMPLETION_DIR) && \
+ 	mkdir -v -p $(FISH_COMPLETION_DIR) && \
 	cp -v completions/has.bash $(BASH_COMPLETION_DIR)/has && \
-	cp -v completions/_has $(ZSH_COMPLETION_DIR)/_has
+	cp -v completions/_has $(ZSH_COMPLETION_DIR)/_has && \
+	cp -v completions/has.fish $(FISH_COMPLETION_DIR)/has.fish

 # install everything
 install-all: install install-completions
@@ -60,6 +63,7 @@
 uninstall-completions:
 	rm -f $(BASH_COMPLETION_DIR)/has
 	rm -f $(ZSH_COMPLETION_DIR)/_has
+	rm -f $(FISH_COMPLETION_DIR)/has.fish

 uninstall-all: uninstall uninstall-completions

goto-dev-null added a commit to goto-dev-null/has-bash that referenced this pull request Feb 22, 2026
…ull request

Seems to make sense to make them match kdabir#93
goto-dev-null added a commit to goto-dev-null/has-bash that referenced this pull request Feb 22, 2026
Also they were not included in the help output
Seems to make sense to make them match kdabir#93
goto-dev-null added a commit to goto-dev-null/has-bash that referenced this pull request Feb 22, 2026
Also they were not included in the help output
Seems to make sense to make them match kdabir#93
goto-dev-null added a commit to goto-dev-null/has-bash that referenced this pull request Feb 22, 2026
Also they were not included in the help output
Seems to make sense to make them match kdabir#93
@kdabir
kdabir merged commit 6e24326 into kdabir:master Sep 5, 2026
kdabir pushed a commit that referenced this pull request Sep 5, 2026
Also they were not included in the help output
Seems to make sense to make them match #93
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
has 1.6.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* update link by @oooooooo in kdabir/has#90
* docs(README): add mise alternate installation documentation by @jylenhof in kdabir/has#92
* feat: added "just" as supported program by @goto-dev-null in kdabir/has#96
* fix: failing unit test assumes dev has `bc` installed by @goto-dev-null in kdabir/has#98
* feat: add shell completions for bash and zsh by @njg7194 in kdabir/has#93
* fix: color flags not working by @goto-dev-null in kdabir/has#97
* Make HAS_ALLOW_UNSAFE case insensitive (closes #35) by @chiliec in kdabir/has#99
* fix: stopped bzip2 from hanging by @goto-dev-null in kdabir/has#94

## New Contributors
* @oooooooo made their first contribution in kdabir/has#90
* @jylenhof made their first contribution in kdabir/has#92
* @goto-dev-null made their first contribution in kdabir/has#96
* @njg7194 made their first contribution in kdabir/has#93
* @chiliec made their first contribution in kdabir/has#99

**Full Changelog**: https://github.com/kdabir/has/compare/v1.5.2...v1.6.0</pre>
  <p>View the full release notes at <a href="https://github.com/kdabir/has/releases/tag/v1.6.0">https://github.com/kdabir/has/releases/tag/v1.6.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!19964
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Add shell completions

3 participants