メインコンテンツまでスキップ

⚙️ Command Architect

z-shell/zsh-cmd-architect

The Zsh Command Architect allows to copy segments of commands in history, rearrange segments of the current command, and delete segments of the current command. This way user glues commands from parts without using a mouse. Advanced history search (multi-word, without duplicate lines) allows to quickly find the parts.

Command architect keybindings

Key(s)Description
Ctrl-TStart Zsh Command Architect (Z shell binding)
EnterDelete selected segment (when in the command window) or add selected segment (when in the history window)
[ or ]Move active segment (when in the command window)
Shift-left or Shift-rightMove active segment (when in command window)
TabSwitch between the two available windows
g, GBeginning and end of the list
/Start incremental search
EscExit incremental search, clearing filter
<,>, {,}Horizontal scroll
Ctrl-LRedraw the whole display
Ctrl-O, oEnter unique mode (no duplicate lines)
Ctrl-W (in incremental search)Delete whole word
Ctrl-K (in incremental search)Delete whole line
Ctrl-D, Ctrl-UHalf page up or down
Ctrl-P, Ctrl-NPrevious and next (also done with vim's j,k)

Install Zsh Command Architect

Add the following to .zshrc. The config files will be available in ~/.config/zca.

~/.zshrc
zi load z-shell/zsh-cmd-architect

Performance

ZCA is fastest with Zsh before 5.0.6 and starting from 5.2

Fixing tmux, screen, and Linux vt

If TERM=screen-256color (often a case for tmux and screen sessions) then ncv terminfo capability will have 2nd bit set.

This in general means that underlining won't work. To fix this by creating your own ncv=0-equipped terminfo file, run:

{ infocmp -x screen-256color; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t

A file will be created in the directory ~/.terminfo and will be automatically used, tmux and screen will work.

Similar is for Linux virtual terminal:

{ infocmp -x linux; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t

It will not display underline properly, but will instead highlight by a color, which is quite nice. The same will not work for FreeBSD's vt, ZCA will detect if that vt is used and will revert to highlighting elements via reverse mode.