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-/ 已经绑定(bind)到 complete-filename
:
$ bind -l | grep /
"\e/": complete-filename
你可以通过放置来重新绑定(bind)它
"\e/": dabbrev-expand
在您的 ~/.inputrc
或 /etc/inputrc
中。
请注意,它似乎只完成了第一个单词(命令),并且仅来自历史记录,而不是据我所知来自当前命令行。
在 zsh 中,我在手册页中看不到任何执行此操作的内容,但应该可以通过找出适当的 compctl
来实现它。命令(Google mirror)。
关于linux - shell 的动态缩写扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5975801/