[英]Interpolate variables in path (bash command line)
請告訴我,我應該怎么做,在鍵入時在bash命令行中插入變量名?
即$A = ~/tmp/
t $A = ~/tmp/
在tmp文件夾中我有tmp1和tmp2文件夾。
我輸入: cd $A<TAB>
並且什么也沒發生。 如果我添加額外的/並鍵入cd $A/tmp1
,它將在末尾添加額外的空格cd $A/tmp1<space>
。
我想要以下行為: cd $A<TAB>
=====> cd ~/tmp/<without additional space>
有什么建議么?
你需要說:
shopt -s direxpand
現在說:
cd $ A / TAB
(注意TAB之前的/
)將顯示目錄而不添加空格。
從手冊:
direxpand
If set, bash replaces directory names with the results
of word expansion when performing filename completion.
This changes the contents of the readline editing buf‐
fer. If not set, bash attempts to preserve what the
user typed.
而且,不是通過說:
A="~/tmp"
要么
A=~/tmp
說
A="${HOME}/tmp"
首先,您不希望在=
兩側有任何空格。 其次,我對bash
表現出上述方式沒有任何問題。 嘗試:
complete -r
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.