← 返回命令列表

Linux command

bindkey 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List all current key bindings

bindkey

List bindings in a format suitable for .zshrc

bindkey -L

Use Emacs key bindings

bindkey -e

Use Vi key bindings

bindkey -v

Bind a key sequence to a ZLE widget

bindkey '^[[H' beginning-of-line

Bind a key sequence to a string

bindkey -s '^T' 'uptime\n'

Remove a key binding

bindkey -r '^l'

说明

bindkey is a builtin command in Zsh and tcsh shells for managing key bindings. In Zsh, it controls the Zsh Line Editor (ZLE), allowing users to map key sequences to editor widgets or macros. In tcsh, it provides similar functionality for customizing keyboard behavior. Key bindings determine how the shell responds to keyboard input during command-line editing. By default, shells typically use Emacs-style bindings, but Vi-style bindings are also available. To discover a key's escape sequence, press Ctrl+v followed by the key at the command line.

参数

-e
Select Emacs key bindings (default keymap)
-v
Select Vi key bindings, starting in insert mode
-L
List bindings as bindkey commands suitable for .zshrc
-l
List available keymap names
-M _keymap_
Specify keymap for binding operations (emacs, viins, vicmd)
-s
Bind key to a string instead of a widget
-r _key_
Remove binding for the specified key
-p
List bindings for prefix keys

FAQ

What is the bindkey command used for?

bindkey is a builtin command in Zsh and tcsh shells for managing key bindings. In Zsh, it controls the Zsh Line Editor (ZLE), allowing users to map key sequences to editor widgets or macros. In tcsh, it provides similar functionality for customizing keyboard behavior. Key bindings determine how the shell responds to keyboard input during command-line editing. By default, shells typically use Emacs-style bindings, but Vi-style bindings are also available. To discover a key's escape sequence, press Ctrl+v followed by the key at the command line.

How do I run a basic bindkey example?

Run `bindkey` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -e do in bindkey?

Select Emacs key bindings (default keymap)