Léo*_* 준영 6 zsh keyboard-shortcuts
Zsh为Man提供了以下键盘快捷键
Esc+h
我想有一个类似的键盘快捷键,如
Esc+i
如何为Info制作这样的键盘快捷键?
Vil*_*ari 13
这应该做的伎俩:
function run_info() {
# Prepend "info" to the command line and run it.
BUFFER="info $BUFFER"
zle accept-line
}
# Define a widget called "run_info", mapped to our function above.
zle -N run_info
# Bind it to ESC-i.
bindkey "^[i" run_info
Run Code Online (Sandbox Code Playgroud)
只需将其粘贴到一个shell中即可将其试用,然后添加到.zshrc中以获得永久效果.
为了解释代码:一般的想法是我们首先定义一个名为"run_info"的小部件,使用具有相同名称的函数实现.它需要命令行缓冲区并将"info"添加到开头.然后它接受命令行(与按下相同Enter).最后,小部件映射到键盘快捷方式.
您可以阅读zshzle(1)手册页,了解有关这些内容如何工作的更多信息.
| 归档时间: |
|
| 查看次数: |
1754 次 |
| 最近记录: |