feat: add shell completions for bash and zsh#93
Open
njg7194 wants to merge 1 commit intokdabir:masterfrom
Open
feat: add shell completions for bash and zsh#93njg7194 wants to merge 1 commit intokdabir:masterfrom
njg7194 wants to merge 1 commit intokdabir:masterfrom
Conversation
- 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
Contributor
|
Love this! Can createa a separate PR if need be but here's a port of what you did for 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds shell completion support for both Bash and Zsh.
Changes
completions/has.bash)completions/_has)install-completionsanduninstall-completionstargetsUsage
After installation, users will get tab-completion for:
-q,-h,--help,-v,--version,--color-*)Closes #65