Skip to content

feat: Add shell completion support for Bash, Zsh, and Fish#1

Merged
code-retriever merged 1 commit into
code-retriever:mainfrom
TWUW-b:feature/shell-completion
Dec 4, 2025
Merged

feat: Add shell completion support for Bash, Zsh, and Fish#1
code-retriever merged 1 commit into
code-retriever:mainfrom
TWUW-b:feature/shell-completion

Conversation

@TWUW-b
Copy link
Copy Markdown
Contributor

@TWUW-b TWUW-b commented Dec 3, 2025

Summary

Implement tab completion functionality for the bmc command across all major shells (Bash, Zsh, Fish).

Features

  • Bash completion (completions/bmc.bash)

    • Command and bookmark name completion
    • Tag completion for list --tag
    • Support for all aliases
  • Zsh completion (completions/_bmc)

    • Detailed argument parsing with _arguments
    • Command descriptions
    • Alias normalization
  • Fish completion (completions/bmc.fish)

    • Visual feedback
    • Rule-based completion definitions
    • Auto-loading from ~/.config/fish/completions/
  • Test suite (tests/test_completion.bats)

    • Output parsing tests
    • Syntax validation
    • Performance tests

Implementation

  • Leverages existing bmc list output (no core code changes)
  • Uses NO_COLOR=1 for clean parsing
  • Handles all command aliases (g/go, rm/remove, etc.)
  • Supports bm command alias

Usage Examples

bmc <TAB>            # Show all commands
bmc g <TAB>          # Show bookmark list
bmc g sam<TAB>       # Complete to 'sample-project'
bmc list --tag <TAB> # Show available tags

Setup

Setup instructions for all three shells have been added to README.md.

Bash

source ~/.local/share/bookmark-cli/completions/bmc.bash

Zsh

fpath=(~/.local/share/bookmark-cli/completions $fpath)
autoload -Uz compinit && compinit

Fish

ln -s ~/.local/share/bookmark-cli/completions/bmc.fish ~/.config/fish/completions/

Test Plan

  • Bash completion syntax validated
  • Zsh completion syntax validated
  • Bookmark name extraction tested
  • All completion scripts created
  • README.md updated with setup instructions
  • Test suite created

Changes

  • Added completions/bmc.bash (101 lines)
  • Added completions/_bmc (123 lines)
  • Added completions/bmc.fish (87 lines)
  • Added tests/test_completion.bats (108 lines)
  • Updated README.md (61 lines added)

Total: 480 insertions

Implement tab completion functionality for bmc command across all major shells.
Users can now press TAB to autocomplete bookmark names, commands, and tags.

Features:
- Bash completion (completions/bmc.bash)
- Zsh completion with descriptions (completions/_bmc)
- Fish completion with visual feedback (completions/bmc.fish)
- Bookmark name completion for 'go', 'remove', 'rename' commands
- Tag completion for 'list --tag' command
- Full command and alias support
- Test suite for completion functionality

Implementation:
- Leverages existing 'bmc list' output (no core changes)
- Uses NO_COLOR=1 for clean parsing
- Handles all command aliases (g/go, rm/remove, etc.)
- Support for 'bm' command alias

Usage:
  bmc g <TAB>          # Show bookmark list
  bmc g sam<TAB>       # Complete to 'sample-project'
  bmc list --tag <TAB> # Show available tags

Setup instructions added to README.md for all three shells.
@code-retriever code-retriever merged commit 71a336a into code-retriever:main Dec 4, 2025
@code-retriever
Copy link
Copy Markdown
Owner

Awesome work!

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.

2 participants