Questions about command completion in the Bash Unix shell.
Questions tagged [bash-completion]
310 questions
                    
                    185
                    
            votes
                
                7 answers
            
        Git tab completion not working in zsh on mac
No matter what I try and do I can't seem to make git tab/auto completion work in my zsh shell. I've downloaded the bash-completion script and the zsh-completion one and followed the instructions, but I can't make it work. 
I've reinstalled oh-my-zsh…
         
    
    
        hamchapman
        
- 2,901
- 4
- 22
- 37
                    118
                    
            votes
                
                2 answers
            
        A confusion about ${array[*]} versus ${array[@]} in the context of a bash completion
I'm taking a stab at writing a bash completion for the first time, and I'm a bit confused about about the two ways of dereferencing bash arrays (${array[@]} and ${array[*]}).
Here's the relevant chunk of code (it works, but I would like to…
         
    
    
        Telemachus
        
- 19,459
- 7
- 57
- 79
                    97
                    
            votes
                
                8 answers
            
        Running bash commands in the background without printing job and process ids
To run a process in the background in bash is fairly easy.
$ echo "Hello I'm a background task" &
[1] 2076
Hello I'm a background task
[1]+  Done                    echo "Hello I'm a background task"
However the output is verbose. On the first line…
         
    
    
        Alex Spurling
        
- 54,094
- 23
- 70
- 76
                    64
                    
            votes
                
                2 answers
            
        Python argparse and bash completion
I would like to get auto-completion on my python scripts also in the arguments.
I had never really understood how the bash_completion worked (for arguments), but after I digged in I understood that:
it uses "complete" to bind a completing function…
         
    
    
        andrea_crotti
        
- 3,004
- 2
- 28
- 33
                    59
                    
            votes
                
                8 answers
            
        bash completion of makefile target
Suppose I have a simple makefile like:
hello:
   echo "hello world"
bye:
   echo "bye bye"
Then in bash I want something like:
make h < tab >
so it can complete to
make hello
I found a simple way like creating empty files hello and bye but I'm…
         
    
    
        Guillaume Massé
        
- 8,004
- 8
- 44
- 57
                    58
                    
            votes
                
                1 answer
            
        Get autocompletion when invoking a "read" inside a Bash script
Inside my Bash script, I'm reading some variables entered by the user with read:
read -p "Glassfish Path:" GF_DIR
Now I want that the user gets a autocompletion when he has to enter a directory, like when you are on the Bash shell. So when he…
         
    
    
        Wolkenarchitekt
        
- 20,170
- 29
- 111
- 174
                    43
                    
            votes
                
                3 answers
            
        Bash variable expansion on tab complete
I'm running Ubuntu 11.04, and I'm seeing some odd behaviour when I try to use tab-completion in bash on a path that starts with a variable.  If I've got TOP=/scratch, and I try to tab-complete:
cd $TOP/foo
it changes to:
cd \$TOP/foo
I'd prefer it…
         
    
    
        sholte
        
- 1,295
- 1
- 9
- 11
                    38
                    
            votes
                
                8 answers
            
        Cygwin git tab completion
I installed Cygwin on windows and one of the default packages is git tab completion, but I don't have tab completion.
I did some searching and found a note saying it isn't enabled by default. I copied the skel .bashrc and .bash_profile to ~ and in…
         
    
    
        JAyenGreen
        
- 1,385
- 2
- 12
- 23
                    34
                    
            votes
                
                6 answers
            
        bash and readline: tab completion in a user input loop?
I'm making a bash script which presents a command line to the user.
The cli code is as this:
#!/bin/bash
cmd1() {
    echo $FUNCNAME: "$@"
}
cmd2() {
    echo $FUNCNAME: "$@"
}
cmdN() {
    echo $FUNCNAME: "$@"
}
__complete() {
    echo…
         
    
    
        ata
        
- 2,045
- 1
- 14
- 19
                    30
                    
            votes
                
                1 answer
            
        Bash completion: Honor repository-specific Git alias in alias completion
Say bash is configured with the following alias:
alias up="git --git-dir /path/to/backup/.git"
And that particular repository - and only that repository - has the following git alias:
[alias]
backup = commit --allow-empty-message
How can up…
         
    
    
        user19087
        
- 1,899
- 1
- 16
- 21
                    30
                    
            votes
                
                6 answers
            
        Getting compgen to include slashes on directories when looking for files
I'd like to get the following behavior from my custom completion
Given
$ mkdir foo
$ touch foo faz/bar faz/baz
I'd like to get this
$ foo -u  =>
foo faz/
$ foo -u fa =>
foo -u faz/
$ foo -u faz/ =>
bar baz
I assumed…   
         
    
    
        Trygve Laugstøl
        
- 7,440
- 2
- 36
- 40
                    29
                    
            votes
                
                5 answers
            
        Getting "complete" and "menu-complete" to work together
I found out that the Bash shell supports a type of autocompletion that is different from the "traditional" autocompletion, where all possibilities get listed on the following line.
With the "traditional" autocompletion, if I type ch and then press…
         
    
    
        kYuZz
        
- 1,572
- 4
- 14
- 25
                    26
                    
            votes
                
                3 answers
            
        Multi Level Bash Completion
I currently have a Bash completion file which completes a single parameter from a list of allowed commands for a script called pbt. This is the working Bash completion file:
_pbt_complete()
{
    local cur goals
    COMPREPLY=()
   …
         
    
    
        Wolkenarchitekt
        
- 20,170
- 29
- 111
- 174
                    26
                    
            votes
                
                4 answers
            
        Accessing bash completions for specific commands programmatically
I'm trying to write a small command launcher application, and would like to use bash's tab completions in my own completion system. I've been able to get a list of completions for general commands using compgen -abck.
However, I would also like to…
         
    
    
        Donald Harvey
        
- 917
- 8
- 23
                    26
                    
            votes
                
                1 answer
            
        How to reset COMP_WORDBREAKS without affecting other completion script?
There is something confuse me when I implement a bash auto-completion function which I'll put it in /etc/bash_completion.d/
In order to achieve some feature, I want to remove the word break characters colon (:) from variable $COMP_WORDBREAKS and add…
         
    
    
        Raymond
        
- 375
- 4
- 8