2012-02-01 273 views
0

有沒有辦法在命令行上「擴展」bash別名並獲得它後面的命令? 因此,它會例如將ls變成;bash別名expantion

ls --color=auto 

我不斷進入的情況下,當我的別名做幾乎是我想做的事,但不完全...

這是可能的所有建議或讚賞

+0

嘗試別名嗎?嘿嘿 – Jasonw 2012-02-01 07:37:10

回答

1

答案嘗試

$ alias alias_name 

它會顯示給定別名的擴展名

1

一個更復雜的方式,它適用於呼應:

$ cut -d = -f1 --complement< <(alias alias_name) | tr '"'"'" ' ' 

所以,在像

exp() { 
    cmd=$1 
    shift 
    echo $(cut -d = -f1 --complement< <(alias $cmd) | tr '"'"'" ' ') [email protected] 
} 

會導致呼應的命令,因爲它會被髮布到外殼的功能,所有的擴展後,到位。

這對調試可能很有用。

$ exp ll .* 
ls -l --color=tty . .. .bash_history .bash_logout .bash_profile .bashrc .lesshst