2011-05-12 44 views
2

有一個像emacs dabbrev-expand的linux shell的功能嗎?殼的動態縮略擴展

+0

另請參閱:[引用第一個參數路徑的快捷方式](http://stackoverflow.com/questions/5505827/is-there-any-shortcut-to-reference-the-path-of-the-第一個參數在mv命令)爲不同的方式來實現類似的東西。 – Mikel 2011-05-12 09:41:42

回答

3

首先給出一個定義:

的Mx描述功能輸入 dabbrev-擴大輸入

... 
Expands to the most recent, preceding word for which this is a prefix. 

鑑於bash似乎是最沉重的Emacs的影響,尋找有首先揭示幾種可能性:

man bash(1), readline section

dynamic-complete-history (M-TAB) 
    Attempt completion on the text before point, comparing the text 
    against lines from the history list for possible completion matches. 
dabbrev-expand 
     Attempt menu completion on the text before point, comparing the text 
     against lines from the history list for possible completion matches. 

默認情況下(或我的系統至少),M-/已經綁定到complete-filename

$ bind -l | grep/
"\e/": complete-filename 

你可以重新綁定它通過把

"\e/": dabbrev-expand 
您的 ~/.inputrc/etc/inputrc中的

請注意,它似乎只完成第一個單詞(命令),並且只能從歷史記錄中,而不是從當前命令行完成,據我所知。

在zsh中,我看不到這樣做的手冊頁中有任何內容,但應該可以通過找出適當的compctl命令(Google mirror)來實現。

+0

非常感謝!你知道如何調用與特定鍵無關的emacs-like bash函數嗎? – paweloque 2011-05-12 11:11:48