Skip to content

feat: add shell completions for bash and zsh#93

Open
njg7194 wants to merge 1 commit intokdabir:masterfrom
njg7194:add-shell-completions
Open

feat: add shell completions for bash and zsh#93
njg7194 wants to merge 1 commit intokdabir:masterfrom
njg7194:add-shell-completions

Conversation

@njg7194
Copy link
Copy Markdown

@njg7194 njg7194 commented Feb 1, 2026

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
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

2 participants