Hasty Briefsbeta

Writing Your Own Simple Tab-Completions for Bash and Zsh

14 days ago
  • #bash-zsh
  • #shell-scripting
  • #tab-completion
  • Shell tab-completions can be set up for both Bash and Zsh, despite their different APIs.
  • Basic tab completion involves registering a handler function that generates possible completions based on the current input.
  • Zsh supports completion descriptions natively, while Bash requires a workaround to display descriptions.
  • A hack for Bash involves appending descriptions to completions, making them visible without being inserted into the command line.
  • To show descriptions for single completions, an additional 'dummy' completion is added to force the shell to display the description.
  • The final implementation provides a consistent user experience across both shells, including descriptions for all completions.