【问题标题】:Dynamic abbrev expand for the shell外壳的动态缩写展开
【发布时间】:2011-05-12 09:13:51
【问题描述】:

在其中一个 linux shell 上是否有类似 emacs dabbrev-expand 的功能?

【问题讨论】:

标签: linux shell emacs


【解决方案1】:

首先给出一个定义:

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-/ 已经绑定到complete-filename

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

你可以把它重新绑定

"\e/": dabbrev-expand

在您的~/.inputrc/etc/inputrc 中。

请注意,据我所知,它似乎只完成了第一个单词(命令),并且仅来自历史记录,而不是来自当前命令行。

在 zsh 中,我在手册页中看不到任何执行此操作的内容,但应该可以通过找出适当的 compctl 命令 (Google mirror) 来实现它。

【讨论】:

  • 非常感谢!你知道如何调用未绑定到特定键的类似 emacs 的 bash 函数吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-14
  • 1970-01-01
相关资源
最近更新 更多