Skip to content

Commit f3c37f5

Browse files
Add zsh and bash completion scripts for mat-cli (#1)
1 parent 67e6175 commit f3c37f5

18 files changed

Lines changed: 2062 additions & 213 deletions

File tree

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,63 @@ npx skills add https://github.com/Demogorgon314/mat-cli --skill mat-cli-heapdump
4646
2. Unzip it.
4747
3. Run `./mat-cli --help` from the extracted directory.
4848

49+
### Shell Completion
50+
51+
`mat-cli` ships first-party `bash` and `zsh` completion scripts in the release archive:
52+
53+
- `completion/bash/mat-cli`
54+
- `completion/zsh/_mat-cli`
55+
56+
You can also generate the same scripts at runtime:
57+
58+
```bash
59+
./mat-cli completion bash
60+
./mat-cli completion zsh
61+
```
62+
63+
Temporary activation in the current shell:
64+
65+
```bash
66+
source <(./mat-cli completion bash)
67+
source <(./mat-cli completion zsh)
68+
```
69+
70+
Persistent `bash` installation:
71+
72+
```bash
73+
mkdir -p ~/.local/share/bash-completion/completions
74+
cp ./completion/bash/mat-cli ~/.local/share/bash-completion/completions/mat-cli
75+
```
76+
77+
Or generate it directly:
78+
79+
```bash
80+
mkdir -p ~/.local/share/bash-completion/completions
81+
./mat-cli completion bash > ~/.local/share/bash-completion/completions/mat-cli
82+
```
83+
84+
Persistent `zsh` installation:
85+
86+
```bash
87+
mkdir -p ~/.zfunc
88+
cp ./completion/zsh/_mat-cli ~/.zfunc/_mat-cli
89+
```
90+
91+
Or generate it directly:
92+
93+
```bash
94+
mkdir -p ~/.zfunc
95+
./mat-cli completion zsh > ~/.zfunc/_mat-cli
96+
```
97+
98+
If your `zsh` setup does not already load `~/.zfunc`, add this once to your shell startup file before `compinit`:
99+
100+
```zsh
101+
fpath=(~/.zfunc $fpath)
102+
autoload -Uz compinit
103+
compinit
104+
```
105+
49106
## Requirements
50107

51108
- Java 17 or newer to run the standalone release
@@ -68,6 +125,7 @@ Useful discovery commands:
68125
- `mat-cli schema <command> --format json`
69126
- `mat-cli list-queries --format json`
70127
- `mat-cli describe-query <query-id> --format json`
128+
- `mat-cli completion <bash|zsh>`
71129

72130
## Example Workflows
73131

features/org.eclipse.mat.cli.feature/build.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ bin.includes = feature.xml,\
22
build.properties
33

44
root=file:rootfiles/notice.html,\
5-
file:rootfiles/.eclipseproduct
5+
file:rootfiles/.eclipseproduct,\
6+
file:rootfiles/completion/bash/mat-cli,\
7+
file:rootfiles/completion/zsh/_mat-cli
68

79
root.win32.win32.x86_64=file:rootfiles/win32/mat-cli.bat
810

0 commit comments

Comments
 (0)