use*_*107 3 bash io-redirection autocomplete
当我在ls
命令后对参数使用制表符完成时,它可以工作,但是当我在某个脚本参数之后使用它时(参见下面的第二个示例),它不起作用。我已经检查过选项卡完成是否已启用。如何为所有命令运行选项卡完成?
注意:screen
如果这很重要,我将在会话中(在 Ubuntu 上)运行它。
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"
Run Code Online (Sandbox Code Playgroud)
Bash 版本:GNU bash,版本 4.3.11(1)-release (x86_64-pc-linux-gnu)
尝试等效:
$ ./script.sh &> test[TAB]
Run Code Online (Sandbox Code Playgroud)
这&>
是将 stdout 和 stderr 重定向到文件的首选语法。
制表符完成将 ( >&
) 视为其他一些语法并且不显示文件。