Você pode executar o widget pelo widget execute-named-cmd
, que está vinculado a ESC-x
(ligações do emacs) ou :
(ligações do vi):
execute-named-cmd (ESC-x) (:) (unbound)
Read the name of an editor command and execute it.
Isto abre um mini-buffer abaixo da linha de comando, onde você pode iniciar widgets zle. (Autocompletion está disponível!):
$ [ESC-x]
execute: set-[TAB]
set-local-history set-mark-command
Para consultar o estado de zle
(incluindo o histórico local), use a variável $ZLE_STATE
(acessível somente dentro das funções do widget):
ZLE_STATE (scalar)
Contains a set of space-separated words that describe the current zle state.
Currently, the states shown are the insert mode as set by the overwrite-mode or vi-replace widgets and whether history commands will visit imported entries as controlled by the set-local-history widget. The string contains
insert
if characters to be inserted on the command line move existing characters to the right oroverwrite
if characters to be inserted overwrite existing characters. It containslocalhistory
if only local history commands will be visited orglobalhistory
if imported history commands will also be visited.The substrings are sorted in alphabetical order so that if you want to test for two specific substrings in a future-proof way, you can do match by doing:
if [[ $ZLE_STATE == *globalhistory*insert* ]]; then ...; fi
Todas as citações de man zshzle
.