
bash
在這個系統上使用:
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux
序列:
cd /tmp
touch test1.txt && touch test2.txt && touch test3.txt
ls test [tab][tab]
顯示:
test1.txt test2.txt test3.txt
在命令列下方。
這就是我期望bash
自動完成的行為。
但是當我輸入:
ls test* [tab][tab]
(期望相同的結果)我只得到(即自動完成完全擴展到):
test1.txt
因此*
末尾的星號 () 通配符會導致test[23].txt
「無法存取」。我非常確定這兩個序列在先前版本的 bash 中給出了相同的結果——至少在我的計算機上是這樣。
有其他人有這個問題嗎?它是可以更改的預設設定(例如在 Debian 8 中)嗎? (我嘗試設定和取消設定不同的 shell 參數,shopt
但沒有成功)。
答案1
那麼對我有用的解決方案是這樣的:~/.bashrc
我有以下幾行
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
fi
fi
我認為這是負責自動完成的區塊。在將其註解掉並啟動新的 shell 之後,它不僅可以工作,而且又回到了我習慣的方式!
仍然不確定if
-clause 是什麼意思,但我不會在它工作時嘗試修復它。