ZSH历史完成菜单

Ole*_*jev 11 shell zsh autocomplete

Zsh自动完成是惊人的,但我无法正确配置一件事:我希望zsh为我提供历史记录中的命令列表.

我知道我可以用Ctrl+ 搜索历史R,但我想要一些不同的东西.当我输入:

shelajev @ elephant~»kill 1 TAB
1642 shelajev gnome-keyring-d
1718 shelajev gnome-session
1807 shelajev ssh-agent
1810 shelajev dbus-launch
1811 shelajev dbus-daemon
1822 shelajev gnome-settings-
1884 shelajev gvfsd
1891 shelajev gvfs-fuse-daemo

Zsh为我提供了一系列杀人程序.我想要这样的东西:

shelajev @ elephant~»杀死Ctrl+ X Ctrl+ X
杀死-9 12093
杀死-15 4123

列表中的这些项目取自我的历史记录.

存在ZLE hist-complete的东西,但我不知道如何正确配置它.

我有以下内容.zshrc:

zle -C hist-complete complete-word _generic
zstyle ':completion:hist-complete:*' completer _history
bindkey "^X^X" hist-complete
Run Code Online (Sandbox Code Playgroud)

但这只能完成个别单词,这对我没有多大帮助.有没有办法为结合历史搜索线的历史和展示的一个列表?

Ken*_*ent 14

在zsh中有一些叫做的东西history-beginning-search-menu.如果你把:

autoload -Uz history-beginning-search-menu
zle -N history-beginning-search-menu
bindkey '^X^X' history-beginning-search-menu
Run Code Online (Sandbox Code Playgroud)

在.zshrc文件中.然后例如:

kent$  sudo systemctl[here I type C-X twice]
Enter digits:
01 sudo systemctl acpid.service                      11 sudo systemctl enable netfs
02 sudo systemctl enable acpid                       12 sudo systemctl enable networkmanager
03 sudo systemctl enable alsa                        13 sudo systemctl enable NetworkManager
04 sudo systemctl enable alsa-restore                14 sudo systemctl enable NetworkManager-wait-online
05 sudo systemctl enable alsa-store                  15 sudo systemctl enable ntpd
06 sudo systemctl enable cronie                      16 sudo systemctl enable sshd
07 sudo systemctl enable cups                        17 sudo systemctl enable syslog-ng
08 sudo systemctl enable dbus                        18 sudo systemctl enable tpfand
09 sudo systemctl enable gdm                         19 sudo systemctl reload gdm.service
10 sudo systemctl enable hal                         20 sudo systemctl restart gdm.service
Run Code Online (Sandbox Code Playgroud)

那么您需要提供索引号以在历史记录中触发命令.

当然可以有一些优化.但我想这会让你开始.

希望能帮助到你.


Mar*_*ert 8

我的Zsh 自动完成插件包括一个适当的历史菜单,以及实时多行历史搜索。尝试一下,让我知道你的想法!

实时历史搜索

具有多选功能的历史菜单