はじめに
macOS のデフォルトのシェルが zsh になって久しいのですけども、zsh といえば補完が強力、なんてことを私は知ってはいてもどうこうできるわけもなく、何となく普通に使っておりましたけれど、何でも詰め合わせ的にいい感じに補完を強化してくれるやつがあるらしいじゃないっすか。ってことで追加してみました。
インストール
% brew install zsh-completions
インストールはいつものように Homebrew さんに頼るのが良い感じですね。今回もしっかりとお世話になりました。というか、あれですよね、何かしらインストールの必要性があったら、とりあえず brew search
してみるっていう。
設定
上記コマンドを実行するだけで、インストールは筒がなく終了するのですけども、その途中で、「有効にしたいなら、以下のコマンドをログイン時に実行するんだ」みたいなことまで教えてくれるので、.zshrc なり .zprofile なりに以下を追記します。
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh-completions:$FPATH
autoload -Uz compinit
compinit
fi
Homebrew さん、優しい、優しいわ!
補完
はい、それでは一旦ログアウトして、別タブなりウィンドウなりを開いて再度ログインしましょう。適当なコマンドを入力して tab をパン。
tac@rina zsh % brew
--cache -- Display Homebrew's download cache
--caskroom -- Display Homebrew's Caskroom path
--cellar -- Display Homebrew's Cellar path
--env -- Summarise Homebrew's build environment as a plain list
--prefix -- Display Homebrew's install path
--repository -- Display where Homebrew's git repository is located
--version -- Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask
analytics -- Control Homebrew's anonymous aggregate user behaviour analytics
audit -- Check formula for Homebrew coding style violations
autoremove -- Uninstall formulae that were only installed as a dependency of another formula and are n
bottle -- Generate a bottle (binary package) from a formula that was installed with `--build-bottl
bump -- Display out-of-date brew formulae and the latest version available
bump-cask-pr -- Create a pull request to update cask with a new version
bump-formula-pr -- Create a pull request to update formula with a new URL or a new tag
bump-revision -- Create a commit to increment the revision of formula
bump-unversioned-casks -- Check all casks with unversioned URLs in a given tap for updates
casks -- List all locally installable casks including short names
cat -- Display the source of a formula or cask
cleanup -- Remove stale lock files and outdated downloads for all formulae and casks, and remove ol
command -- Display the path to the file being used when invoking `brew` cmd
commands -- Show lists of built-in and external commands
completions -- Control whether Homebrew automatically links external tap shell completion files
config -- Show Homebrew and system configuration info useful for debugging
create -- Generate a formula or, with `--cask`, a cask for the downloadable file at URL and open i
deps -- Show dependencies for formula
desc -- Display formula's name and one-line description
dispatch-build-bottle -- Build bottles for these formulae with GitHub Actions
doctor -- Check your system for potential problems
edit -- Open a formula or cask in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the H
extract -- Look through repository history to find the most recent version of formula and create a
fetch -- Download a bottle (if available) or source packages for formulae and binaries for casks
formula -- Display the path where formula is located
formulae -- List all locally installable formulae including short names
gist-logs -- Upload logs for a failed build of formula to a new Gist
home -- Open a formula or cask's homepage in a browser, or open Homebrew's own homepage if no ar
info -- Display brief statistics for your Homebrew installation
install -- Install a formula or cask
install-bundler-gems -- Install Homebrew's Bundler gems
irb -- Enter the interactive Homebrew Ruby shell
leaves -- List installed formulae that are not dependencies of another installed formula
link -- Symlink all of formula's installed files into Homebrew's prefix
linkage -- Check the library links from the given formula kegs
list -- List all installed formulae and casks
livecheck -- Check for newer versions of formulae and/or casks from upstream
log -- Show the `git log` for formula, or show the log for the Homebrew repository if no formul
man -- Generate Homebrew's manpages
migrate -- Migrate renamed packages to new names, where formula are old names of packages
mirror -- Reupload the stable URL of a formula to Bintray for use as a mirror
missing -- Check the given formula kegs for missing dependencies
options -- Show install options specific to formula
outdated -- List installed casks and formulae that have an updated version available
pin -- Pin the specified formula, preventing them from being upgraded when issuing the `brew up
postinstall -- Rerun the post-install steps for formula
pr-automerge -- Find pull requests that can be automatically merged using `brew pr-publish`
pr-publish -- Publish bottles for a pull request with GitHub Actions
pr-pull -- Download and publish bottles, and apply the bottle commit from a pull request with artif
pr-upload -- Apply the bottle commit and publish bottles to a host
prof -- Run Homebrew with a Ruby profiler
readall -- Import all items from the specified tap, or from all installed taps if none is provided
reinstall -- Uninstall and then reinstall a formula or cask using the same options it was originally
release -- Create a new draft Homebrew/brew release with the appropriate version number and release
release-notes -- Print the merged pull requests on Homebrew/brew between two Git refs
rubocop -- Installs, configures and runs Homebrew's `rubocop`
ruby -- Run a Ruby instance with Homebrew's libraries loaded
search -- Perform a substring search of cask tokens and formula names for text
sh -- Enter an interactive shell for Homebrew's build environment
shellenv -- Print export statements
sponsors -- Update the list of GitHub Sponsors in the `Homebrew/brew` README
style -- Check formulae or files for conformance to Homebrew style guidelines
tap -- Tap a formula repository
tap-info -- Show detailed information about one or more taps
tap-new -- Generate the template files for a new tap
test -- Run the test method provided by an installed formula
tests -- Run Homebrew's unit and integration tests
typecheck -- Check for typechecking errors using Sorbet
unbottled -- Show the unbottled dependents of formulae
uninstall -- Uninstall a formula or cask
unlink -- Remove symlinks for formula from Homebrew's prefix
unpack -- Unpack the source files for formula into subdirectories of the current working directory
unpin -- Unpin formula, allowing them to be upgraded by `brew upgrade` formula
untap -- Remove a tapped formula repository
update -- Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and per
update-license-data -- Update SPDX license data in the Homebrew repository
update-maintainers -- Update the list of maintainers in the `Homebrew/brew` README
update-python-resources -- Update versions for PyPI resource blocks in formula
update-report -- The Ruby implementation of `brew update`
update-reset -- Fetch and reset Homebrew and all tap repositories (or any specified repository) using `g
update-test -- Run a test of `brew update` with a new repository clone
upgrade -- Upgrade outdated casks and outdated, unpinned formulae using the same options they were
uses -- Show formulae and casks that specify formula as a dependency; that is, show dependents o
vendor-gems -- Install and commit Homebrew's vendored gems
vendor-install -- Install Homebrew's portable Ruby
aspell-dictionaries postgresql-upgrade-database services
こんな感じでドン。
おわりに
そこそこいい感じに対応していますけれど、たくさんたくさん対応しているわけではないので、良くお使いのコマンドとかが対応していなかったら喜びも薄いと思うのですけど、手軽に導入できますので試してみると良いと思いますよ。