This Zsh plugin enables you to run typed zsh command without triggering new prompt, history entry, or having output being outputed.
Here is a (now a outdated 📜) preview 🎬:
This plugins define several zle widgets to run commands from the shell as variant of classic accept-line:
-
quiet-accept-line: Run the current typed command, without outputting a new prompt (it removes and rewrite buffer)- bound to C-x RET/C-x C-m, ESC ENTER, (this is Alt enter on macos). Configurable with
ZLE_QAL_QUIET_KEY - output can be piped to a custom program/function with
ZLE_QAL_COMMAND
- bound to C-x RET/C-x C-m, ESC ENTER, (this is Alt enter on macos). Configurable with
-
pager-accept-line: Run the current typed command forwarding output in pager, preserve(restore) existing prompt- bound to both C-x C-RET/C-x C-m, ESC CTRL-ENTER AND A-C-m, CTRL-ALT-ENTER (overridable with
ZLE_QAL_PAGER_KEYandZLE_QAL_PAGER_KEY2) - pager configurable with
ZLE_QAL_PAGER, default to less
- bound to both C-x C-RET/C-x C-m, ESC CTRL-ENTER AND A-C-m, CTRL-ALT-ENTER (overridable with
-
compact-accept-line: run the current typed command persisting a more compact prompt- bound to \C-N/C-n,(overridable with
ZLE_QAL_COMPACT_KEY) - compact prompt default to
$bold, configurable withZLE_QAL_COMPACT_PROMPT
- bound to \C-N/C-n,(overridable with
-
silent-accept-line: Run the current typed command, without outputting a new prompt. Output will be suppressed- bound to ^X^\C-N aka ESC C-N (overridable with
ZLE_QAL_SILENT_KEY) - content is dump in a temporary file (
/tmp/zsh-quiet-accept-line-silent-$$.logpattern). It can be configured withZLE_QAL_SILENT_DUMP_FILEor disabled setting this env var to/dev/null
- bound to ^X^\C-N aka ESC C-N (overridable with
-
last-quiet-accept-linebound to C-x C-k: restore to the prompt the last command that was run with `quiet/silent-accept-line`` -
history-ignore-accept-line: run the current typed command prefixing it with a space so it's not stored in history- bound to C-x C-SPC (overridable with
ZLE_QAL_HISTORY_IGNORE_KEY)
- bound to C-x C-SPC (overridable with
Optionaly status code of the quietly runned command can be display.
To do so, set ZLE_QAL_STATUS_DISPLAY to true, on or yes.
(QAL stands for Quiet Accept Line)
Also note, after running a command, the eventual commands that where pushed with an ESC-Q are restored.
Just source quiet-accept-line content, or if you use a plugin manager set adrieankhisbe/zsh-quiet-accept-line as plugin:
- for antigen, just add zsh-quiet-accept-line to your bundles as
adrieankhisbe/zsh-quiet-accept-lineantigen bundle adrieankhisbe/zsh-quiet-accept-line - same for antidote and antibody
- for zplug, add
zplug "adrieankhisbe/zsh-quiet-accept-line"
Keys can be configured based on the following variables and relatable defaults:
ZLE_QAL_QUIET_KEY(default^X^M, Ctrl-X Ctrl-M)ZLE_QAL_SILENT_KEY(default^X^J, Ctrl-X Ctrl-J)ZLE_QAL_COMPACT_KEY(default^N, Ctrl-N)ZLE_QAL_PAGER_KEY(default^X^\C-M, Ctrl-X ESC Ctrl-M)ZLE_QAL_PAGER_KEY2(default\e^\C-M, ESC Ctrl-M)ZLE_QAL_LAST_KEY(default^X^K, Ctrl-X Ctrl-K)ZLE_QAL_HISTORY_IGNORE_KEY(default^X^, Ctrl-X Ctrl-Space)
Output of the status code can be customized with the following variable:
ZLE_QAL_STATUS_DURATION: how long status is displayed, blocking the prompt (default 0.5s)ZLE_QAL_STATUS_OK: what is output for successful command (default green✔with prompt color escape%{%})ZLE_QAL_STATUS_KO: what is output for failing command (default red✖with prompt color escape%{%}) note that status is saved toZLE_QAL_STATUSvariable
As mention in usage, some behavior can be configured, notably:
ZLE_QAL_COMMAND: command to pipe command logs forquiet-accept-lineZLE_QAL_PAGER: pager forpager-accept-line, default to$PAGERZLE_QAL_SILENT_DUMP_FILEdefault to (/tmp/zsh-quiet-accept-line-silent-$$.log), disable with/dev/nullZLE_QAL_COMPACT_PROMPT: compact prompt forcompact-accept-linedefault%B$%b
This plugin was driven by the need to improve tmux-resurrect zsh history saving that was poluting terminal with fc commands.
After some research I end up on the following stack overflow question, that inspired the initial implementation.
