Zsh自动补全功能非常出色,但我无法正确地配置其中一项:我想让zsh从历史记录中为我提供一个命令列表。
我知道可以使用Ctrl+R来搜索历史记录,但我想要的略有不同。当我输入:
shelajev@elephant ~ » kill 1TAB
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 ~ » kill Ctrl+X Ctrl+X
kill -9 12093
kill -15 4123
其中列表中的项目是从我的历史记录中获取的。
虽然存在ZLE hist-complete功能,但我不知道如何正确配置它。
在我的.zshrc
中,我有以下内容:
zle -C hist-complete complete-word _generic
zstyle ':completion:hist-complete:*' completer _history
bindkey "^X^X" hist-complete
但这仅仅是针对单个单词的搜索,帮助有限。是否有一种方法可以结合历史记录中行的搜索,并显示列表呢?