linux - shell 的动态缩写扩展

标签 linux shell emacs

Linux shell 之一是否有像 emacs dabbrev-expand 这样的功能?

最佳答案

先给个定义:

M-xdescribe-functionEnterdabbrev-expandEnter

...
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-/ 已经绑定(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/

相关文章:

linux - 如何调用 BASH 中的程序执行的大量配对文件?

shell - Cloudformation 无法识别 UserData 脚本中的 Shell 变量

linux - bash 没有正确解析 (cat + grep)

ruby-on-rails - 为 Vista 和 Windows Server 2008 的开发双引导设置 Unix

emacs - 调用 nrepl-jack-in 时杀死以前的 nrepl session ?

C 程序可以编译,但执行后立即终止

php - 如何找到与一台主机关联的所有 ips?

linux - shell 脚本到 ls 并在 ls 结果上执行命令

Emacs lua 模式问题 : (void-function interactively-called-p)

c++ - 从 malloc() 进行的 Windows 和 Linux native 操作系统/系统调用是什么?