← 返回命令列表

Linux command

zle 命令

文本

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

常用示例

Define

zle -N [widget_name] [function_name]

List

zle -l

List

zle -la

List

zle -lL

Delete

zle -D [widget_name]

Create

zle -A [old_widget] [new_widget]

Invoke

zle [widget_name]

Display

zle -M "[message]"

说明

zle is a builtin command of zsh that controls the Zsh Line Editor, the interactive command-line editing subsystem. It manages widgets (named editing actions), keymaps, display control, and the edit buffer. When called with no arguments, it returns zero if ZLE is currently active. Full documentation is in the zshzle(1) man page. ZLE activates automatically in interactive zsh sessions. It operates in multiline mode (default) or single-line mode (when the SINGLE_LINE_ZLE option is set). Special parameters like BUFFER, CURSOR, LBUFFER, and RBUFFER allow widget functions to manipulate the edit buffer directly.

参数

-N _widget_ _function_
Define a new user-defined widget backed by a shell function. If function is omitted, defaults to the widget name
-C _widget_ _completion-widget_ _function_
Create a user-defined completion widget inheriting behavior from an existing builtin completion widget
-l -L | -a
List user-defined widgets. -L: format as zle commands. -a: include builtins
-D _widget ..._
Delete named user-defined widgets
-A _old-widget_ _new-widget_
Create an alias; both names refer to the same widget
-R -c _display-string_ _string ..._
Redisplay the command line. Optional display-string appears in status line. -c clears completion lists
-M _string_
Display a message string below the command line that persists after the widget returns
-U _string_
Push characters onto ZLE's input stack for processing after the current widget finishes
-K _keymap_
Select the named keymap for subsequent keystrokes
-F -Lw _fd_ [_handler_]
Install or remove a handler for a file descriptor. -w: handler is a widget. -L: list handlers
-I
Invalidate the current display before external output
-f _flag ..._
Set flags on the current widget: yank, yankbefore, kill, vichange, nolast

FAQ

What is the zle command used for?

zle is a builtin command of zsh that controls the Zsh Line Editor, the interactive command-line editing subsystem. It manages widgets (named editing actions), keymaps, display control, and the edit buffer. When called with no arguments, it returns zero if ZLE is currently active. Full documentation is in the zshzle(1) man page. ZLE activates automatically in interactive zsh sessions. It operates in multiline mode (default) or single-line mode (when the SINGLE_LINE_ZLE option is set). Special parameters like BUFFER, CURSOR, LBUFFER, and RBUFFER allow widget functions to manipulate the edit buffer directly.

How do I run a basic zle example?

Run `zle -N [widget_name] [function_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -N _widget_ _function_ do in zle?

Define a new user-defined widget backed by a shell function. If function is omitted, defaults to the widget name