Bash tab completion not working in >& redirection

autocompletebashio-redirection

When I use tab completion on an argument after ls command it works, but when I use it after some script argument (see second example below) it does not work. I have checked that tab completion is enabled. How to make tab completion run for all commands?

Note: I'm running this in a screen session (on Ubuntu) if that matters.

user$ echo $SHELL
/bin/bash
user$ grep completion ~/.bashrc
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
user$ 
user$ ls test[TAB]
test.log1                                               
test.log2                                                
test.log4                                              
test.log5                                              

user$ ./script.sh >& test[TAB]  <-- "no output"

Bash version: GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

Best Answer

Try the equivalent:

$ ./script.sh &> test[TAB]

The &> is the preferred syntax for redirecting both stdout and stderr to a file.

Tab-completion sees that (>&) as some other syntax and doesn't show the files.

Related Question