Skip to content

feat: per-command toggle for real-time completion (closes #776)#867

Open
palemoky wants to merge 1 commit into
marlonrichert:mainfrom
palemoky:feature/per-command-toggle
Open

feat: per-command toggle for real-time completion (closes #776)#867
palemoky wants to merge 1 commit into
marlonrichert:mainfrom
palemoky:feature/per-command-toggle

Conversation

@palemoky

Copy link
Copy Markdown

What

Adds two zstyle options to selectively enable or disable real-time autocompletion per command, as requested in #776:

# Blacklist: autocomplete everything EXCEPT these commands.
zstyle ':autocomplete:*' disabled-commands 'ls' 'cd' 'pwd'

# Whitelist: autocomplete ONLY these commands.
zstyle ':autocomplete:*' enabled-commands 'git' 'curl' 'docker' 'kubectl'

I used zstyle rather than the plain shell variables originally sketched in the issue, to stay consistent with every other configuration option in the plugin (min-input, ignored-input, etc.).

Why

Per #776 (5 👍): users want to hide completions for commands where they aren't helpful (like ls), or keep them only where they are (like git/curl), and reduce overhead on slower systems.

How

  • New helper .autocomplete:async:command-disabled, wired into .autocomplete:async:complete (the line-pre-redraw hook) before the async completion machinery starts — so suppressed commands skip the work entirely, addressing the performance motivation.
  • enabled-commands (whitelist) takes precedence over disabled-commands (blacklist).
  • Setting neither is a complete no-op: every command completes, exactly as today.
  • Values are glob patterns (e.g. 'kube*').
  • Matches both the command as typed and its base name (/usr/bin/lsls).
  • Skips leading VAR=value assignments and precommand modifiers, so sudo ls matches ls.
  • Never suppresses completion of the command name currently being typed, so command-name completion always works — including in whitelist mode.

Tests

  • Existing suite: 51/51 pass.
  • Manually exercised the matching logic across blacklist/whitelist, glob patterns, sudo, full paths, VAR= assignments, and command-name typing.

Closes #776

- add enabled-commands (whitelist) and disabled-commands (blacklist) styles
- skip variable assignments and precommands like sudo when matching
- never suppress command-name completion; whitelist takes precedence
- document the new styles in README
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.

Add the ability to selectively enable/disable autocompletion for specific commands through whitelist/blacklist configuration.

1 participant