Skip to content

Commit cb513bf

Browse files
committed
new file: .config/zca/h-list.conf
new file: .config/zca/zca.conf new file: .pre-commit-config.yaml new file: LICENSE new file: README.md new file: doc/generate_single_file new file: doc/install.sh new file: h-list new file: h-list-draw new file: h-list-input new file: zca new file: zca-usetty-wrapper new file: zca-widget new file: zsh-cmd-architect.plugin.zsh
0 parents  commit cb513bf

File tree

14 files changed

+2310
-0
lines changed

14 files changed

+2310
-0
lines changed

.config/zca/h-list.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Should the list (text, borders) be drawn in bold
2+
# Value 1 is the default
3+
local bold=1

.config/zca/zca.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# How should be current element of the list drawn. Possible values: reverse,
2+
# underline. Default (without option set) is reverse
3+
# On Linux virtual terminal this will be enforced to reverse (because of poor
4+
# underline support on that terminal)
5+
local active_text=underline
6+
7+
# Highlight a few keywords
8+
local HLIST_COLORING_PATTERN="(while|for |sudo|make|(#s)git|vim(#e)|vim |emacs(#e)|emacs )"
9+
local HLIST_COLORING_COLOR=$'\x1b[00;33m'
10+
local HLIST_COLORING_MATCH_MULTIPLE=1

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.0.1
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/thlorenz/doctoc
12+
rev: v2.1.0
13+
hooks:
14+
- id: doctoc

LICENSE

Lines changed: 700 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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.

doc/generate_single_file

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/zsh
2+
3+
local PLUGIN_FILE="doc/zshcmdarchitect.plugin.zsh"
4+
5+
[ -d doc ] || cd ..
6+
7+
rm -vf "$PLUGIN_FILE"
8+
echo "# https://github.com/z-shell/zsh-cmd-architect" >>"$PLUGIN_FILE"
9+
echo "# License is GPLv3 and MIT" >>"$PLUGIN_FILE"
10+
echo -n "# " >>"$PLUGIN_FILE"
11+
git show-ref master | head -1 >>"$PLUGIN_FILE"
12+
echo >>"$PLUGIN_FILE"
13+
14+
for i in h-*(on) zca zca-*(on); do
15+
echo "$i() {" >>"$PLUGIN_FILE"
16+
cat "$i" >>"$PLUGIN_FILE"
17+
echo "}" >>"$PLUGIN_FILE"
18+
echo >>"$PLUGIN_FILE"
19+
done
20+
21+
# Append ^R bind
22+
echo "zle -N zca-widget" >>"$PLUGIN_FILE"
23+
echo "bindkey '^T' zca-widget" >>"$PLUGIN_FILE"

doc/install.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
3+
if ! type git 2>/dev/null 1>&2; then
4+
echo "Please install GIT first"
5+
echo "Exiting"
6+
exit 1
7+
fi
8+
9+
#
10+
# Clone or pull
11+
#
12+
13+
if ! test -d "$HOME/.config"; then
14+
mkdir "$HOME/.config"
15+
fi
16+
17+
if ! test -d "$HOME/.config/zca"; then
18+
mkdir "$HOME/.config/zca"
19+
fi
20+
21+
echo ">>> Downloading zsh-cmd-architect to ~/.config/zca"
22+
if test -d ~/.config/zca/zsh-cmd-architect; then
23+
cd ~/.config/zca/zsh-cmd-architect
24+
git pull origin master
25+
else
26+
cd ~/.config/zca
27+
git clone https://github.com/z-shell/zsh-cmd-architect.git zsh-cmd-architect
28+
fi
29+
echo ">>> Done"
30+
31+
#
32+
# Copy configs
33+
#
34+
35+
echo ">>> Copying config files"
36+
37+
cd ~/.config/zca
38+
39+
set h-list.conf zca.conf
40+
41+
for i; do
42+
if ! test -f "$i"; then
43+
cp -v zsh-cmd-architect/.config/zca/$i .
44+
fi
45+
done
46+
47+
echo ">>> Done"
48+
49+
#
50+
# Modify .zshrc
51+
#
52+
53+
echo ">>> Updating .zshrc"
54+
if ! grep zsh-cmd-architect ~/.zshrc >/dev/null 2>&1; then
55+
echo >>~/.zshrc
56+
echo "### ZCA's installer added snippet ###" >>~/.zshrc
57+
echo "fpath=( \"\$fpath[@]\" \"\$HOME/.config/zca/zsh-cmd-architect\" )" >>~/.zshrc
58+
echo "autoload h-list zca zca-usetty-wrapper zca-widget" >>~/.zshrc
59+
echo "zle -N zca-widget" >>~/.zshrc
60+
echo "bindkey '^T' zca-widget" >>~/.zshrc
61+
echo "### END ###" >>~/.zshrc
62+
echo ">>> Done"
63+
else
64+
echo ">>> .zshrc already updated, not making changes"
65+
fi

0 commit comments

Comments
 (0)