Creating a bash completion script
In this post I will familiarize you with the process of adding bash completion to your scripts.
What is bash completion?
Bash completion is a functionality through which bash helps users type their commands faster and easier. It accomplishes that by presenting possible options when users press the tab
key while typing a command.
$ git<tab><tab> git git-receive-pack git-upload-archive gitk git-shell git-upload-pack $ git-s<tab> $ git-shell
How it works
The completion script is code that uses the builtin bash command complete
to define which completion suggestions can be displayed for a given executable. The nature of the completion options vary from simple static to highly sophisticated.
Why bother
It is good to provide such a functionality to users:
- to save them from typing text when it can be auto-completed
- to help them know what are the available continuations to their commands
- to prevent errors and improve their experience by hiding or showing options based on what they have already typed
Read full article from Creating a bash completion script
No comments:
Post a Comment