Skip to content

Commit 982f9e0

Browse files
committed
Iteration option and per-plugin completion plus more plugins.
1 parent b6b92bb commit 982f9e0

File tree

7 files changed

+1120
-746
lines changed

7 files changed

+1120
-746
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
SHELL := /bin/bash
22
all: test www
33

4-
test: unit lint
5-
6-
unit:
7-
./test/cztest
4+
test: lint unit structure
85

96
lint:
107
shellcheck ./cz
118

9+
unit:
10+
./test/unit
11+
12+
structure:
13+
./test/structure
14+
1215
WWW_SOURCES := $(wildcard www/*.org)
1316

1417
%.html: %.org
@@ -23,7 +26,7 @@ www/:
2326
mkdir -p ./www
2427

2528
gif:
26-
gifcut -b1 "$$(capture -Wt20)" "www/img/window-$$(date +%s).gif"
29+
gifcut -b1 "$$(capture -W)" "www/img/window-$$(date +%s).gif"
2730

2831
push:
2932
git push github

README.md

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -71,77 +71,80 @@ bash\`.
7171

7272
## Usage
7373

74-
cz [OPTIONS] [PLUGIN...] [ARGS ...] [< LINES]
75-
Select a line using your preferred interactive line selection tool.
76-
77-
OPTIONS
78-
These options print some information then exit:
79-
-h : help : Show this help text or help text for plugin.
80-
-H : example : List example commands.
81-
-k : tools : List supported line selection tools.
82-
-l : plugins : List detected plugins.
83-
-v : version : Show version string.
84-
85-
These options set the program mode. Select a line then... :
86-
-p : print : Print the line. This is the default mode.
87-
-q : quoted : Print fields from the line in shell quotes.
88-
-r : run : Run a templated command.
89-
-s : simulate : Print a templated command.
90-
-t : template : Print a templated string.
91-
-u : unquoted : Print fields from the line literally.
92-
-o : : Only print input lines instead of selecting a line.
93-
94-
These options set a template:
95-
-e TEMPLATE : Set the command template. This option implies mode '-r'.
96-
-f FIELDS : Set the field template. This option implies mode '-q'.
97-
98-
These options control input and line splitting:
99-
-c : Do not use cached input lines.
100-
-d DELIMITER : Set the field splitting characters.
101-
-g : Buffer stdin and pass it to command set with '-e'.
102-
-0 : Read null terminated lines from input.
103-
-i IN-FILE : Set file from which to read selections instead of stdin.
104-
105-
These options control how lines are selected:
106-
-w : Pick a line at random.
107-
-x : Use a graphical line selection tool.
108-
-y : Use a terminal line selection tool.
109-
-z TOOL : Use the given line selection tool.
110-
111-
These options control debugging features:
112-
-m : Print some debygging information.
113-
114-
TOOLS
115-
The following interactive line selection tools are supported:
116-
choose, dmenu, fzf, fzy, gum, iselect, pick, pipedial, rofi, selecta,
117-
sentaku, slmenu, vis-menu, and zenity.
118-
119-
PLUGINS
120-
Plugins use cz for an application specific task. Each plugin defines input
121-
lines, delimiter, and template options.
122-
Run 'cz -l' to list plugins and 'cz -h PLUGIN' or 'cz help' for help text.
123-
All commands starting with 'cz_' are considered plugins.
124-
125-
TEMPLATES
126-
Sub-strings of TEMPLATE in the following formats are replaced with
127-
one or more fields from a selected line split by DELIMITER.
128-
{X} - field X
129-
{X:} - fields X through end of fields
130-
{X:Y} - fields X through X + Y
131-
{X,Y,Z} - fields X, Y, and Z
132-
133-
Append @C, @E, @P, or @Q to transform selected fields:
134-
{X@C} - Insert argument directly. This is risky for command strings!
135-
{X@E} - Replace backslash escape sequences in arguments with bash $'...' quotes.
136-
{X@P} - Expand arguments for use in prompt strings.
137-
{X@Q} - Quote arguments for use in command input. This is the default.
138-
139-
ENVIRONMENT
140-
CZ_GUI : The preferred interface (1=graphical 0=terminal).
141-
CZ_BINS : A list of line selection tools in order of preference.
142-
CZ_DMENU_COLOR : Colon separated colors for dmenu (NF:NB:SF:SB).
143-
CZ_DMENU_FONT : The font to use for dmenu.
144-
CZ_ROFI_THEME : The theme to use for rofi.
74+
``` text
75+
cz [OPTIONS] [PLUGIN...] [ARGS ...] [< LINES]
76+
Select a line using an interactive line selection tool.
77+
78+
OPTIONS
79+
These options print some information then exit:
80+
-h : help : Show this help text or help text for plugin.
81+
-H : example : List example commands.
82+
-k : tools : List supported line selection tools.
83+
-l : plugins : List detected plugins.
84+
-v : version : Show version string.
85+
86+
These options set the program mode. Select a line then... :
87+
-p : print : Print the line. This is the default mode.
88+
-q : quote : Print fields from the line in shell quotes.
89+
-r : run : Run a templated command.
90+
-s : simulate : Print a templated command.
91+
-t : template : Print a templated string.
92+
-u : unquote : Print fields from the line literally.
93+
-o : output : Only print input lines instead of selecting a line.
94+
95+
These options set a template:
96+
-e TEMPLATE : Set the command template. This option implies mode '-r'.
97+
-f FIELDS : Set the field template. This option implies mode '-q'.
98+
99+
These options control input and line splitting:
100+
-c : Do not use cached input lines.
101+
-d DELIMITER : Set the field splitting characters.
102+
-g : Buffer stdin and pass it to command set with '-e'.
103+
-0 : Read null terminated lines from input.
104+
-i IN-FILE : Set file from which to read selections instead of stdin.
105+
106+
These options control how lines are selected:
107+
-n NUMBER : Select a line the given number of times.
108+
-w : Pick a line at random.
109+
-x : Use a graphical line selection tool.
110+
-y : Use a terminal line selection tool.
111+
-z TOOL : Use the given line selection tool.
112+
113+
These options control debugging features:
114+
-m : Print some debugging information.
115+
116+
TOOLS
117+
The following interactive line selection tools are supported:
118+
choose, dmenu, fzf, fzy, gum, iselect, pick, pipedial, rofi, selecta,
119+
sentaku, slmenu, vis-menu, and zenity.
120+
121+
PLUGINS
122+
Plugins use cz for an application specific task. Each plugin defines input
123+
lines, delimiter, and template options.
124+
Run 'cz -l' to list plugins and 'cz -h PLUGIN' or 'cz help' for help text.
125+
All commands starting with 'cz_' are considered plugins.
126+
127+
TEMPLATES
128+
Sub-strings of TEMPLATE in the following formats are replaced with
129+
one or more fields from a selected line split by DELIMITER.
130+
{X} - field X
131+
{X:} - fields X through end of fields
132+
{X:Y} - fields X through X + Y
133+
{X,Y,Z} - fields X, Y, and Z
134+
135+
Append @C, @E, @P, or @Q to transform selected fields:
136+
{X@C} - Insert argument directly. This is risky for command strings!
137+
{X@E} - Replace backslash escape sequences in arguments with bash $'...' quotes.
138+
{X@P} - Expand arguments for use in prompt strings.
139+
{X@Q} - Quote arguments for use in command input. This is the default.
140+
141+
ENVIRONMENT
142+
CZ_GUI : The preferred interface (1=graphical 0=terminal).
143+
CZ_BINS : A list of line selection tools in order of preference.
144+
CZ_DMENU_COLOR : Colon separated colors for dmenu (NF:NB:SF:SB).
145+
CZ_DMENU_FONT : The font to use for dmenu.
146+
CZ_ROFI_THEME : The theme to use for rofi.
147+
```
145148

146149
## Configuration
147150

conf/cz.bashrc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ export CZ_GUI=0
1313

1414
# Core Functionality
1515
# Insert selected cz plugin output into the readline buffer at cursor
16-
bind -x '"\C-xx":rleval cz meta -q' # insert field(s)
17-
bind -x '"\C-xX":rleval cz meta -p' # insert line
18-
bind -x '"\C-xz":rleval cz meta -r' # insert command output
19-
bind -x '"\C-xZ":rleval cz meta -s' # insert command string
20-
bind -x '"\C-xc":cz meta -r' # just run command
16+
bind -x '"\C-xx":rleval cz meta -q' # insert field(s)
17+
bind -x '"\C-xX":rleval cz meta -p' # insert line
18+
bind -x '"\C-xz":rleval cz meta -r' # insert command output
19+
bind -x '"\C-xZ":rleval cz meta -s' # insert command string
20+
bind -x '"\C-xc":cz meta -r' # just run command
2121

2222
# Shell Utilities
2323
# Insert text useful in the shell
24-
bind -x '"\C-xr":rleval cz -q bash history' # insert selected line from bash history
25-
bind -x '"\C-x!":rleval cz -q argv {0:}' # insert word selected from current readline buffer
26-
bind -x '"\C-xu":rleval cz -q unicode' # insert selected unicode character
24+
bind -x '"\C-xr":rleval -i cz -q bash history {0}' # insert selected line from bash history matching current word
25+
bind -x '"\C-x!":rleval -i cz -q argv {0:}' # insert word selected from current readline buffer
26+
bind -x '"\C-xu":rleval -i cz -u unicode character' # insert selected unicode character
27+
bind -x '"\C-xU":rleval -i cz -u unicode symbol' # insert selected unicode symbol
28+
bind -x '"\C-x,":rleval -w cz -q whence {0}' # replace word with matching command path
2729

2830
# Directory Navigation
2931
# Change directory to selected directory above or below current directory
@@ -33,7 +35,7 @@ bind -x '"\C-x>":cz -re "cd {0}" descendant'
3335
# Git
3436
# Insert selected paths from git repo in the current directory into the readline buffer
3537
bind -x '"\C-xg":rleval cz -q git status' # insert path of selected modified file
36-
bind -x '"\C-xG":rleval cz -q git file' # insert path of selected git tracked file
38+
bind -x '"\C-xG":rleval cz -q git file' # insert path of selected git tracked file
3739

3840
# File Lookup
3941
# Replace the word under readline cursor with a selected file

0 commit comments

Comments
 (0)