<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.define-technology.com/mediawiki-1.35.0/index.php?action=history&amp;feed=atom&amp;title=Linux%3A_Bash_Completion</id>
	<title>Linux: Bash Completion - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?action=history&amp;feed=atom&amp;title=Linux%3A_Bash_Completion"/>
	<link rel="alternate" type="text/html" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Linux:_Bash_Completion&amp;action=history"/>
	<updated>2026-05-05T02:49:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Linux:_Bash_Completion&amp;diff=3998&amp;oldid=prev</id>
		<title>Michael: Created page with &quot;== Bash Completion ==  Hitting the tab to see available options can make life a lot easier.  To add a new command to it you need to create the relevent file in /etc/bash_compl...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Linux:_Bash_Completion&amp;diff=3998&amp;oldid=prev"/>
		<updated>2014-02-11T14:40:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Bash Completion ==  Hitting the tab to see available options can make life a lot easier.  To add a new command to it you need to create the relevent file in /etc/bash_compl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Bash Completion ==&lt;br /&gt;
&lt;br /&gt;
Hitting the tab to see available options can make life a lot easier.  To add a new command to it you need to create the relevent file in /etc/bash_completion.d/ and then update the completions.&lt;br /&gt;
&lt;br /&gt;
== Create a competion file for a command ==&lt;br /&gt;
&lt;br /&gt;
Below is an example file for the command foo.  It has to options show and configure.  Each of these then have sub options. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
_foo()&lt;br /&gt;
{&lt;br /&gt;
    local cur prev&lt;br /&gt;
&lt;br /&gt;
    cur=${COMP_WORDS[COMP_CWORD]}&lt;br /&gt;
    prev=${COMP_WORDS[COMP_CWORD-1]}&lt;br /&gt;
&lt;br /&gt;
    case ${COMP_CWORD} in&lt;br /&gt;
        1)&lt;br /&gt;
            COMPREPLY=($(compgen -W &amp;quot;configure show&amp;quot; ${cur}))&lt;br /&gt;
            ;;&lt;br /&gt;
        2)&lt;br /&gt;
            case ${prev} in&lt;br /&gt;
                configure)&lt;br /&gt;
                    COMPREPLY=($(compgen -W &amp;quot;CM DSP NPU&amp;quot; ${cur}))&lt;br /&gt;
                    ;;&lt;br /&gt;
                show)&lt;br /&gt;
                    COMPREPLY=($(compgen -W &amp;quot;some other args&amp;quot; ${cur}))&lt;br /&gt;
                    ;;&lt;br /&gt;
            esac&lt;br /&gt;
            ;;&lt;br /&gt;
        *)&lt;br /&gt;
            COMPREPLY=()&lt;br /&gt;
            ;;&lt;br /&gt;
    esac&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
complete -F _foo foo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Source the completion file to update ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
source /etc/bash_completion&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Michael</name></author>
	</entry>
</feed>