【发布时间】:2011-05-12 09:13:51
【问题描述】:
在其中一个 linux shell 上是否有类似 emacs dabbrev-expand 的功能?
【问题讨论】:
-
另请参阅:shortcut to reference the path of the first argument,了解实现类似目标的不同方法。
在其中一个 linux shell 上是否有类似 emacs dabbrev-expand 的功能?
【问题讨论】:
首先给出一个定义:
M-xdescribe-functionEnterdabbrev-expandEnter
...
Expands to the most recent, preceding word for which this is a prefix.
鉴于bash 似乎受 Emacs 影响最大,首先查看那里会发现一些可能性:
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) 来实现它。
【讨论】: