Skip to content

Commit 547a8c3

Browse files
committed
license, man page, shell completions
Signed-off-by: Polina Simonenko <rabarbrablad@gmail.com>
1 parent 65482b3 commit 547a8c3

8 files changed

Lines changed: 390 additions & 2 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Polina Simonenko
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ DIST := dist
55
VERSION ?= dev
66
# Platforms built by `make release`.
77
RELEASE_PLATFORMS ?= darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/386 linux/arm
8+
# Man page and its install location (override with `make install-man MANPREFIX=...`).
9+
MANPAGE := docs/exex.1
10+
MANPREFIX ?= /usr/local/share/man
11+
# Shell-completion install dirs (override per platform, e.g. with brew --prefix).
12+
BASHCOMPDIR ?= /usr/local/etc/bash_completion.d
13+
ZSHCOMPDIR ?= /usr/local/share/zsh/site-functions
14+
FISHCOMPDIR ?= /usr/local/share/fish/vendor_completions.d
815

9-
.PHONY: build lite install test clean release
16+
.PHONY: build lite install install-man install-completions test clean release
1017

1118
# Full build: includes Chroma syntax highlighting (source pane + asm colours).
1219
build:
@@ -20,6 +27,18 @@ lite:
2027
install:
2128
go install -trimpath -ldflags="$(LDFLAGS)" .
2229

30+
# Install the man page into $(MANPREFIX)/man1 (use sudo for a system prefix).
31+
install-man:
32+
install -d "$(MANPREFIX)/man1"
33+
install -m 0644 "$(MANPAGE)" "$(MANPREFIX)/man1/exex.1"
34+
35+
# Install shell completions (override *COMPDIR vars for your platform).
36+
install-completions:
37+
install -d "$(BASHCOMPDIR)" "$(ZSHCOMPDIR)" "$(FISHCOMPDIR)"
38+
install -m 0644 completions/exex.bash "$(BASHCOMPDIR)/exex"
39+
install -m 0644 completions/_exex "$(ZSHCOMPDIR)/_exex"
40+
install -m 0644 completions/exex.fish "$(FISHCOMPDIR)/exex.fish"
41+
2342
test:
2443
go test ./...
2544
go vet -tags lite ./...
@@ -40,7 +59,8 @@ release:
4059
if [ "$$variant" = lite ]; then tags="-tags lite"; suffix="-lite"; fi; \
4160
bin=$(BINARY); [ "$$os" = windows ] && bin=$(BINARY).exe; \
4261
stage=$$(mktemp -d); \
43-
cp docs/config.example.yaml README.md "$$stage/" 2>/dev/null || true; \
62+
cp docs/config.example.yaml README.md LICENSE $(MANPAGE) "$$stage/" 2>/dev/null || true; \
63+
cp -r completions "$$stage/" 2>/dev/null || true; \
4464
echo "building $$os/$$arch ($$variant)"; \
4565
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \
4666
go build $$tags -trimpath -ldflags="$(LDFLAGS)" -o "$$stage/$$bin" . || exit 1; \

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ make lite # lite -> ./exex
6363
make test # go test + lite vet
6464
```
6565

66+
### Man page and shell completions
67+
68+
A man page (`docs/exex.1`) and bash/zsh/fish completions (`completions/`) ship with
69+
the source and release archives. Completions complete the flags, the `-o` view
70+
names, and the `<binary>` argument with both files and command names on `$PATH`
71+
(so `exex ls<Tab>` works).
72+
73+
```sh
74+
make install-man # -> $MANPREFIX/man1/exex.1 (sudo for a system prefix)
75+
make install-completions # -> bash/zsh/fish completion dirs (override *COMPDIR vars)
76+
man exex
77+
```
78+
79+
Or install a single completion by hand:
80+
81+
```sh
82+
# bash: source it, or drop it in a bash-completion dir
83+
source completions/exex.bash
84+
# zsh: put _exex on your $fpath (before compinit), e.g.
85+
cp completions/_exex ~/.zsh/completions/_exex
86+
# fish:
87+
cp completions/exex.fish ~/.config/fish/completions/exex.fish
88+
```
89+
6690
## Usage
6791

6892
```
@@ -195,3 +219,7 @@ So exex is not trying to replace a disassembler-platform or the binutils suite
195219
it's the fast first look: open any ELF/Mach-O/PE, read its layout and code, follow
196220
references and source mappings interactively, and drop to plain text when you need
197221
to script.
222+
223+
## License
224+
225+
exex is released under the MIT License — see [LICENSE](LICENSE).

completions/_exex

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#compdef exex
2+
# zsh completion for exex
3+
#
4+
# Install: put this file (named _exex) in a directory on $fpath, e.g.
5+
# ~/.zsh/completions/_exex with `fpath=(~/.zsh/completions $fpath)` before
6+
# `compinit` in ~/.zshrc.
7+
8+
_exex() {
9+
local -a views
10+
views=(info sections segments symbols strings libs sources disasm disasm-all)
11+
12+
_arguments -s \
13+
'(-d -debug)'{-d,-debug}'[external debug-symbols file or directory]:debug path:_files' \
14+
'-s[search printable strings on startup]:string:' \
15+
'-o[print a view or disassembly to stdout and exit]::view:->oview' \
16+
'-h[show usage and exit]' \
17+
'1:binary:->binary' \
18+
'2:goto (address or symbol):' \
19+
&& return
20+
21+
case $state in
22+
oview)
23+
_describe -t views 'view' views ;;
24+
binary)
25+
# A path to a file, or a command name found on $PATH (exex ls -> /bin/ls).
26+
_alternative \
27+
'commands:command on $PATH:_command_names -e' \
28+
'files:file:_files' ;;
29+
esac
30+
}
31+
32+
_exex "$@"

completions/exex.bash

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# bash completion for exex
2+
#
3+
# Install: source this file from ~/.bashrc, or copy it to a bash-completion dir:
4+
# - Linux: /usr/share/bash-completion/completions/exex
5+
# - Homebrew: "$(brew --prefix)/etc/bash_completion.d/exex"
6+
7+
_exex() {
8+
local cur prev views flags i pos
9+
cur="${COMP_WORDS[COMP_CWORD]}"
10+
prev="${COMP_WORDS[COMP_CWORD-1]}"
11+
views="info sections segments symbols strings libs sources disasm disasm-all"
12+
flags="-s -o -d -debug -h"
13+
14+
# Value completion for the flag immediately before the cursor.
15+
case "$prev" in
16+
-o|--o)
17+
COMPREPLY=( $(compgen -W "$views" -- "$cur") )
18+
return ;;
19+
-d|--d|-debug|--debug)
20+
COMPREPLY=( $(compgen -f -- "$cur") )
21+
return ;;
22+
-s|--s)
23+
return ;; # free-form string
24+
esac
25+
26+
if [[ "$cur" == -* ]]; then
27+
COMPREPLY=( $(compgen -W "$flags" -- "$cur") )
28+
return
29+
fi
30+
31+
# Count positional args already given, mirroring how exex parses the line:
32+
# -d/-debug/-s always take a value; -o takes one only when it's a known view.
33+
pos=0
34+
for (( i=1; i < COMP_CWORD; i++ )); do
35+
case "${COMP_WORDS[i]}" in
36+
-d|--d|-debug|--debug|-s|--s) (( i++ )) ;;
37+
-o|--o)
38+
case "${COMP_WORDS[i+1]}" in
39+
info|sections|segments|symbols|strings|libs|sources|disasm|disasm-all) (( i++ )) ;;
40+
esac ;;
41+
-*) ;;
42+
*) (( pos++ )) ;;
43+
esac
44+
done
45+
46+
# First positional is the binary: complete $PATH commands and files. The
47+
# second (goto: an address or symbol) has no static completion.
48+
if (( pos == 0 )); then
49+
COMPREPLY=( $(compgen -c -- "$cur") $(compgen -f -- "$cur") )
50+
fi
51+
}
52+
complete -F _exex exex

completions/exex.fish

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# fish completion for exex
2+
#
3+
# Install: copy to a fish completions directory, e.g.
4+
# ~/.config/fish/completions/exex.fish
5+
6+
complete -c exex -s s -r -d 'search printable strings on startup'
7+
complete -c exex -s d -l debug -r -d 'external debug-symbols file or directory'
8+
complete -c exex -s o -x \
9+
-a 'info sections segments symbols strings libs sources disasm disasm-all' \
10+
-d 'print a view or disassembly to stdout and exit'
11+
complete -c exex -s h -d 'show usage and exit'
12+
13+
# The binary argument: files (fish completes these by default) plus command
14+
# names on $PATH, so `exex ls` resolves /bin/ls. -k keeps them above files.
15+
complete -c exex -k -a '(__fish_complete_command)' -d 'command on $PATH'

0 commit comments

Comments
 (0)