An introduction to bash completion: part 2
Posted by Steve on Sat 24 Dec 2005 at 03:00 Previously we showed how to add basic completion to commands, using facilities which were already provided by the bash completion routines. In this second part we'll demonstrate how to add completely new custom completion to commands. In part one we looked at adding hostname completion to arbitrary commands by executing: complete -F _known_hosts xvncviewer _known_hosts should be used to handle the completion of arguments to the xvncviewer . If we wish to add custom completion to a command we will instead write our own function, and bind that to the command. A Basic Example As a basic example we'll first look at adding some simple completions to the binary foo --help foo foo /etc/bash_completion.d/foo . This file will be automatically sourced (or loaded) when the bash completion code is loaded. Inside that file save the following text:Read full article from An introduction to bash completion: part 2
No comments:
Post a Comment