Add zsh completion scripts for Bitcoin Core command-line tools #33404

issue mstampfer openend this issue on September 16, 2025
  1. mstampfer commented at 12:00 pm on September 16, 2025: none

    Please describe the feature you’d like to see added.

    Bitcoin Core currently provides bash completion scripts for bitcoin-cli, bitcoin-tx, and bitcoind in contrib/completions/bash/, and similarly, fish completion scripts are available in contrib/completions/fish/, but there are no equivalent completion scripts for zsh users. Many developers and users have adopted zsh as their default shell (especially Mac OSX users and with tools like Oh My Zsh), and they cannot benefit from tab completion when using Bitcoin Core command-line tools.

    The potential benefits of adding zsh completions are:

    • Consistent user experience across different shells
    • Reduced typing errors and improved productivity
    • Better discoverability of Bitcoin Core command options
    • No impact on existing bash completion functionality

    The existing bash completion scripts are not compatible with zsh due to differences in:

    • Completion function syntax and structure
    • Array handling and word splitting
    • Built-in completion functions (compgen vs _describe, _files, etc.)

    Describe the solution you’d like

    Add zsh completion scripts that provide the same functionality as the existing bash completions, but using zsh’s native compdef system. These would include:

    • _bitcoin-cli: Complete RPC commands, options, and context-sensitive arguments (e.g., boolean values for specific commands, file paths for wallet operations)
    • _bitcoin-tx: Complete transaction creation options and commands with proper argument handling
    • _bitcoind: Complete daemon configuration options with file/directory path completion

    I have already converted the existing bash completion scripts to zsh format and can provide a pull request with the implementation. The scripts maintain feature parity with the bash versions while using zsh-native completion functions for better integration and performance.

    The scripts would be located in contrib/completions/zsh/ following the same organizational structure as the bash completions.

    Describe any alternatives you’ve considered

    1. Using bash completion in zsh: While zsh can source bash completions with bashcompinit, this provides suboptimal performance and doesn’t integrate well with zsh’s completion system. Not all Bash completion scripts will work perfectly in Zsh; advanced Bash-specific functions may fail.
    2. Manual completion: Users currently have to type commands and options manually without any completion assistance
    3. Third-party solutions: No comprehensive third-party zsh completions exist for Bitcoin Core tools

    Please leave any additional context

    • zsh is the default shell on macOS since Catalina (10.15) and is increasingly popular among developers
    • The implementation would convert existing bash completion logic to zsh equivalents while maintaining all current functionality
    • This would improve developer experience and reduce command-line errors for zsh users
    • Similar completion script for zsh have been made to other major open-source projects
  2. mstampfer added the label Feature on Sep 16, 2025


mstampfer

Labels
Feature


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-19 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me