Skip to content
HKDevLoopsPublic

About

A simple function to add and manage shell completions across all shells; auto-indexes with carapace.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

 ██████╗ ██████╗ ███╗   ███╗██████╗ ██╗     ███████╗████████╗███████╗██████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██║     ██╔════╝╚══██╔══╝██╔════╝██╔══██╗
██║     ██║   ██║██╔████╔██║██████╔╝██║     █████╗     ██║   █████╗  ██████╔╝
██║     ██║   ██║██║╚██╔╝██║██╔═══╝ ██║     ██╔══╝     ██║   ██╔══╝  ██╔══██╗
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║     ███████╗███████╗   ██║   ███████╗██║  ██║
 ╚═════╝ ╚═════╝ ╚═╝     ╚═╝╚═╝     ╚══════╝╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝

completer

ci license: MIT shells version

One small function. Fifteen shells. Zero startup tax.

Tired of Googling "how to enable tab completion in yet another shell" every time you switch terminals? Same. So completer bundles the native completion glue for every shell in one lazy, modular place — then gets out of your way.

This is not a CLI you install. Not a binary. Not a daemon that eats your RAM for breakfast. It's a shell function per shell, written in that shell's own native language, that generates completions from any program and wires them into your config — only when you ask it to.

Who is this for? completer is built for command-line tools that expose a completion keyword in their subcommands — e.g. <program> completion, <program> completions, or a --generate-completion / --completions flag (think opencode completion, gh completion, docker completion). It calls that keyword, captures the program's own completion script, and wires it into your shell using only native APIs. Programs without such a keyword still work through a carapace <program> <shell> fallback, with a small built-in native spec for known exceptions (e.g. opencode on Nushell/Xonsh).


The vibe

  • Native-only. Every shell uses its own documented API. No cross-shell hacks, no eval soup, no wrapper executable.
  • Zero startup cost. Sourcing the file only defines functions. No probing, no carapace/zoxide calls, no file writes at load. Your shell opens exactly as fast as it did before.
  • Modular by design. Your main config keeps one guarded source block. Everything else lives in a sibling completer/ folder next to it.
  • Re-run safe. Existing files are backed up to .bak.<timestamp>; generated blocks are marker-wrapped and replaced, never duplicated. Idempotent or bust.
  • Plugs into carapace & zoxide. completer update carapace refreshes the index using carapace's own CLI; completer zoxide emits native cd init. Next shell launch, it just works.
  • Self-aware. completer completes its own subcommands, shell names, and aliases.
  • Hardened installers. HTTPS-only fetches, optional SHA-256 verification, private staging, symlink refusal, and quote-escaped generated lines.

Supported shells

Shell File Shell File
PowerShell 7+ (pwsh) completer.ps1 Elvish completer.elv
Windows PowerShell 5.1 completer.ps1 Cmd (cmd.exe + clink) completer.cmd.l
Bash completer.bash Tcsh / csh completer.tcsh
Zsh completer.zsh Ksh (ksh93 / mksh) completer.ksh
Fish completer.fish Ion completer.ion
POSIX sh completer.sh Oil (osh / ysh) completer.oil
Nushell completer.nu Yash completer.yash
Xonsh completer.xsh Carapace the engine, not a target

Config file each shell is linked from

Shell Main config Link syntax written by the installer
bash ~/.bashrc . '<file>'
zsh ~/.zshrc . '<file>'
fish ~/.config/fish/config.fish source '<file>'
sh (dash/ash) ~/.profile . '<file>'
ksh ~/.kshrc . '<file>'
tcsh ~/.tcshrc source '<file>'
csh ~/.cshrc source '<file>'
ion ~/.config/ion/initrc source '<file>'
elvish ~/.config/elvish/rc.elv eval (slurp < '<file>')
nu ~/.config/nushell/config.nu source '<file>'
xonsh ~/.config/xonsh/.xonshrc execx(open('<file>').read(), 'exec', __xonsh__.ctx)
yash ~/.yashrc . '<file>'
oil (osh/ysh) ~/.config/oils/oshrc source '<file>'
pwsh PowerShell profile . '<file>' (via install.ps1)
cmd (clink) none — clink auto-loads completer.cmd.l from %LOCALAPPDATA%\clink —

Install (30 seconds)

Set the raw base once, then pipe the installer. With a terminal it shows an interactive menu of all 15 shells — you pick the shell(s) your completer function should work in (name or menu number); without a terminal it auto-detects from $SHELL. It then detects your OS + config file, asks permission, backs up, writes the new function file into a sibling completer/ folder, and adds one guarded source block.

POSIX-family shells (bash, zsh, fish, sh, ksh, tcsh, csh, ion, elvish, nu, xonsh, yash, oil, cmd):

export COMPLETER_RAW_BASE=https://raw.githubusercontent.com/HKDevLoops/completer/main
curl -fsSL "$COMPLETER_RAW_BASE/install.sh" | sh              # interactive menu
curl -fsSL "$COMPLETER_RAW_BASE/install.sh" | sh -s -- bash    # install bash directly

PowerShell (7+ / 5.1):

$env:COMPLETER_RAW_BASE = 'https://raw.githubusercontent.com/HKDevLoops/completer/main'
iwr "$env:COMPLETER_RAW_BASE/install.ps1" | iex
# Windows PowerShell 5.1: irm "$env:COMPLETER_RAW_BASE/install.ps1" | iex

Local, from the repo root:

sh ./install.sh                 # menu
sh ./install.sh zsh fish        # specific shells (names or menu numbers 1-15)
. .\install.ps1                 # PowerShell
. .\install.ps1 -LinkMode Symlink   # symlink instead of copy
. .\install.ps1 -NoLink             # install the file only, don't touch the profile

Non-interactive / verified installs:

COMPLETER_YES=1 sh ./install.sh bash                          # skip the y/N prompt
COMPLETER_SHA256=<hex-of-completer.bash> sh ./install.sh bash # verify the download

COMPLETER_RAW_BASE must be an https:// URL (cleartext is refused); curl is additionally pinned to --proto '=https' --tlsv1.2. With COMPLETER_SHA256 set, the staged download is hash-checked before anything is installed.


Usage — the good stuff

completer bash opencode gh docker     # ask any CLI for its completions
completer pwsh                        # target one shell (defaults to opencode)
completer update carapace             # refresh carapace's completion index
completer zoxide                      # native zoxide `cd` init
completer alias add gs 'git status'   # append an alias to alias.<ext>
completer alias remove gs             # ...and take it back out
completer list                        # show what's been generated

Completion sources, in order: the program's own flags (completion --shell, --completions, …) → carapace <prog> <shell> → a built-in native spec for shells a tool can't target directly (looking at you, opencode on nu/xonsh).


How it stays out of your way

<config-dir>/<shell config file> ──(one guarded block)──▶ completer/
                                                      │
                                                      ├─ sources completer.<ext>
                                                      ├─ sources alias.<ext>
                                                      └─ self-completion hook
                                                             │
                                                             ▼
                                                  completions/<shell>-<prog>-completion.<ext>
                                                             ▲
                                       generated on demand, backed up, marker-wrapped

Nothing runs until you call completer.


Project layout

completer.<ext>          # 14 native function files (15 shell targets)
install.sh               # POSIX installer: interactive shell menu / args / env gates
install.ps1              # PowerShell installer: -LinkMode Source|Symlink, -NoLink
alias.<ext>              # per-shell seed alias stores (append/remove methods)
tests/run-tests.sh       # structural + native-parser test harness
tests/functional.sh      # invokes the bash functions in an isolated root
.github/workflows/ci.yml # GitHub Actions: native runners + glibc containers + best-effort exotics
VERSION                  # current release version
LICENSE                  # MIT

No dependencies: the installers use only native shell tools (curl/wget, coreutils, sha256sum/shasum/openssl), and the test harness needs only bash + coreutils. Nothing to pip/npm/cargo install, no vendored code, no compiled binaries.


Testing

bash tests/run-tests.sh

Runs structural checks (files, entrypoints, no compiled binaries) plus native parsers for whichever shells are installed (bash -n, sh -n, PowerShell parser, nu, xonsh), and functional tests that invoke the bash completer in an isolated HOME/COMPLETER_ROOT. CI runs the same harness on Ubuntu, macOS, Windows and a matrix of Linux containers.


License

MIT — do whatever you want, just keep the notice. See LICENSE.

Copyright © 2026 harish2222 (HKDEVS). Built with native shell glue and a mild allergy to startup lag.

About

A simple function to add and manage shell completions across all shells; auto-indexes with carapace.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages