|
| 1 | +# `ZSH-COMMAND-ARCHITECT` |
| 2 | + |
| 3 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 4 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 5 | + |
| 6 | +- [Inroduction](#inroduction) |
| 7 | + - [Installation](#installation) |
| 8 | + - [Installation With Zinit](#installation-with-zinit) |
| 9 | + - [Installation With Zgen](#installation-with-zgen) |
| 10 | + - [Installation With Antigen](#installation-with-antigen) |
| 11 | + - [Manual Installation](#manual-installation) |
| 12 | + - [Single File Manual Installation](#single-file-manual-installation) |
| 13 | + - [Introduction](#introduction) |
| 14 | + - [Performance](#performance) |
| 15 | + - [Fixing tmux, screen and linux vt](#fixing-tmux-screen-and-linux-vt) |
| 16 | + |
| 17 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 18 | + |
| 19 | +# Inroduction |
| 20 | + |
| 21 | +Also check out [Zsh Navigation Tools](https://github.com/z-shell/zsh-navigation-tools) |
| 22 | +and [Zsh Editing Workbench](https://github.com/z-shell/zsh-editing-workbench) |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +```sh |
| 27 | +sh -c "$(curl -fsSL https://raw.githubusercontent.com/z-shell/zsh-cmd-architect/main/doc/install.sh)" |
| 28 | +``` |
| 29 | + |
| 30 | +To update run the command again. |
| 31 | + |
| 32 | +`ZCA` will be installed at `~/.config/zca/zsh-cmd-architect`, config files will be copied to `~/.config/zca`. `.zshrc` |
| 33 | +will be updated with only `4` lines of code that will be added to the bottom. |
| 34 | + |
| 35 | +After installing and reloading shell give `ZCA` a quick try with `Ctrl-T`. |
| 36 | + |
| 37 | +## Installation With [Zinit](https://github.com/z-shell/zinit) |
| 38 | + |
| 39 | +Add `zinit load z-shell/zsh-cmd-architect` to `.zshrc`. The config files will be available in `~/.config/zca`. |
| 40 | + |
| 41 | +## Installation With Zgen |
| 42 | + |
| 43 | +Add `zgen load z-shell/zsh-cmd-architect` to `.zshrc` and issue a `zgen reset` (this assumes that there is a proper `zgen save` construct in `.zshrc`). |
| 44 | +The config files will be available in `~/.config/zca`. |
| 45 | + |
| 46 | +## Installation With Antigen |
| 47 | + |
| 48 | +Add `antigen bundle z-shell/zsh-cmd-architect` to `.zshrc`. There also |
| 49 | +should be `antigen apply`. The config files will be in `~/.config/znt`. |
| 50 | + |
| 51 | +## Manual Installation |
| 52 | + |
| 53 | +After extracting `ZCA` to `{some-directory}` add following two lines to `~/.zshrc`: |
| 54 | + |
| 55 | +```zsh |
| 56 | +fpath+=( {some-directory} ) |
| 57 | +source "{some-directory}/zsh-cmd-architect.plugin.zsh" |
| 58 | +``` |
| 59 | + |
| 60 | +As you can see, no plugin manager is needed to use the `*.plugin.zsh` |
| 61 | +file. The above two lines of code are all that almost **all** plugin |
| 62 | +managers do. In fact, what's actually needed is only: |
| 63 | + |
| 64 | +```zsh |
| 65 | +source "{some-directory}/zsh-cmd-architect.plugin.zsh" |
| 66 | +``` |
| 67 | + |
| 68 | +because `ZCA` detects if it is used by **any** plugin manager and can |
| 69 | +handle `$fpath` update by itself. |
| 70 | + |
| 71 | +## Single File Manual Installation |
| 72 | + |
| 73 | +Running script `doc/generate_single_file` will create single-file version of `ZCA`. |
| 74 | +It can be sourced from `.zshrc`. Don't forget about configuration files (copy them to `~/.config/zca`). |
| 75 | + |
| 76 | +## Introduction |
| 77 | + |
| 78 | +`ZCA` allows to copy segments of commands in history, rearrange segments of current command, |
| 79 | +delete segments of current command. This way user glues command from parts without using |
| 80 | +a mouse. Advanced history search (multi word, without duplicate lines) allows to quickly find |
| 81 | +the parts. |
| 82 | + |
| 83 | +Keys are: |
| 84 | + |
| 85 | +- `Ctrl-T` - start Zsh Command Architect (Zshell binding) |
| 86 | +- `Enter` - delete selected segment (when in command window) or add selected segment (when in history window) |
| 87 | +- `[` or `]` - move active segment (when in command window) |
| 88 | +- `Shift-left` or `Shift-right` - move active segment (when in command window) |
| 89 | +- `Tab` - switch between the two available windows |
| 90 | +- `g, G` - beginning and end of the list |
| 91 | +- `/` - start incremental search |
| 92 | +- `Esc` - exit incremental search, clearing filter |
| 93 | +- `<`,`>`, `{`,`}` - horizontal scroll |
| 94 | +- `Ctrl-L` - redraw of whole display |
| 95 | +- `Ctrl-O`, `o` - enter uniq mode (no duplicate lines) |
| 96 | +- `Ctrl-W` (in incremental search) - delete whole word |
| 97 | +- `Ctrl-K` (in incremental search) - delete whole line |
| 98 | +- `Ctrl-D`, `Ctrl-U` - half page up or down |
| 99 | +- `Ctrl-P`, `Ctrl-N` - previous and next (also done with vim's j,k) |
| 100 | + |
| 101 | +## Performance |
| 102 | + |
| 103 | +`ZCA` is fastest with `Zsh` before `5.0.6` and starting from `5.2` |
| 104 | + |
| 105 | +## Fixing tmux, screen and linux vt |
| 106 | + |
| 107 | +If `TERM=screen-256color` (often a case for `tmux` and `screen` sessions) then |
| 108 | +`ncv` terminfo capability will have `2`nd bit set. This in general means that |
| 109 | +underline won't work. To fix this by creating your own `ncv=0`-equipped |
| 110 | +terminfo file, run: |
| 111 | + |
| 112 | +```zsh |
| 113 | +{ infocmp -x screen-256color; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t |
| 114 | +``` |
| 115 | + |
| 116 | +A file will be created in directory `~/.terminfo` and will be automatically |
| 117 | +used, `tmux` and `screen` will work. Similar is for Linux virtual terminal: |
| 118 | + |
| 119 | +```zsh |
| 120 | +{ infocmp -x linux; printf '\t%s\n' 'ncv@,'; } > /tmp/t && tic -x /tmp/t |
| 121 | +``` |
| 122 | + |
| 123 | +It will not display underline properly, but will instead highlight by a color, |
| 124 | +which is quite nice. The same will not work for FreeBSD's vt, `ZCA` will detect |
| 125 | +if that vt is used and will revert to highlighting elements via `reverse` mode. |
0 commit comments