2011-05-12 47 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