Skip to content

Commit b20582a

Browse files
authored
fix: update zsh completions and README documentation (#10)
- Remove non-existent profiles from zsh completions (node, python, go, git) - Remove aliases using non-existent profiles (sxn, sxp) - Add missing CLI options to zsh completions (--config, --no-config, --trace-file, --allow-read, --allow-write, --deny-read) - Expand README options table with all CLI flags - Improve shell integration docs with Homebrew paths, features, and aliases
1 parent 604ab32 commit b20582a

3 files changed

Lines changed: 67 additions & 36 deletions

File tree

.github/workflows/release.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ jobs:
208208
run: |
209209
mkdir -p dist
210210
cp target/${{ matrix.target }}/release/sx dist/
211+
cp -r shell dist/
211212
cd dist
212-
tar czf sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz sx
213+
tar czf sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz sx shell/
213214
shasum -a 256 sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz > sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz.sha256
214215
215216
- name: Upload artifact

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,20 @@ sx --dry-run rust # Preview sandbox profile
140140
| Option | Description |
141141
|--------|-------------|
142142
| `-v, --verbose` | Show sandbox configuration |
143+
| `-d, --debug` | Enable debug mode (log all denials) |
143144
| `-t, --trace` | Trace sandbox violations in real-time (see note below) |
144145
| `--trace-file <PATH>` | Write trace output to file instead of stderr |
145146
| `-n, --dry-run` | Print sandbox profile without executing |
147+
| `-c, --config <PATH>` | Use specific config file |
148+
| `--no-config` | Ignore all config files |
146149
| `--explain` | Show what would be allowed/denied |
147150
| `--init` | Create `.sandbox.toml` in current directory |
151+
| `--offline` | Block all network (default) |
152+
| `--online` | Allow all network |
153+
| `--localhost` | Allow localhost only |
148154
| `--allow-read <PATH>` | Allow read access to path |
149155
| `--allow-write <PATH>` | Allow write access to path |
156+
| `--deny-read <PATH>` | Deny read access to path (override allows) |
150157

151158
> **Note on `--trace`:** The trace output shows sandbox violations from **all sandboxed processes** on the system, not just the current session. This is a limitation of macOS sandbox logging, which doesn't include session identifiers in denial logs. If you're running multiple `sx` sessions simultaneously, violations from all sessions will appear in each trace output.
152159
@@ -226,24 +233,46 @@ System-wide defaults and custom profiles.
226233

227234
## Shell Integration
228235

229-
Add to your shell config for prompt indicators and tab completion:
236+
Optional shell integration provides prompt indicators, tab completion, and aliases.
230237

231-
**Zsh** (`~/.zshrc`):
238+
### Installation
239+
240+
**Zsh** - Add to `~/.zshrc`:
232241
```bash
242+
# If installed via Homebrew
243+
source $(brew --prefix)/share/sx/sx.zsh
244+
245+
# Or from source
233246
source /path/to/sandbox-shell/shell/sx.zsh
234247
```
235248

236-
**Bash** (`~/.bashrc`):
249+
**Bash** - Add to `~/.bashrc`:
237250
```bash
238-
source /path/to/sandbox-shell/shell/sx.bash
251+
source $(brew --prefix)/share/sx/sx.bash
252+
# Or: source /path/to/sandbox-shell/shell/sx.bash
239253
```
240254

241-
**Fish** (`~/.config/fish/conf.d/`):
255+
**Fish** - Copy to config:
242256
```fish
243-
cp shell/sx.fish ~/.config/fish/conf.d/
257+
cp $(brew --prefix)/share/sx/sx.fish ~/.config/fish/conf.d/
244258
```
245259

246-
Provides: prompt indicator, tab completion, aliases (`sxo`, `sxl`, `sxr`).
260+
### Features
261+
262+
**Prompt indicator** - Shows sandbox mode with color coding:
263+
- `[sx:offline]` (red) - Network blocked
264+
- `[sx:localhost]` (yellow) - Localhost only
265+
- `[sx:online]` (green) - Full network access
266+
267+
**Aliases:**
268+
| Alias | Command | Description |
269+
|-------|---------|-------------|
270+
| `sxo` | `sx online` | Full network access |
271+
| `sxl` | `sx localhost` | Localhost only |
272+
| `sxr` | `sx online rust` | Rust with network |
273+
| `sxc` | `sx online gpg claude` | Claude Code with GPG |
274+
275+
**Tab completion** - Complete profiles, options, and commands.
247276

248277
## Development
249278

shell/sx.zsh

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,53 @@ _sx() {
2828
'base:Minimal sandbox (always included)'
2929
'online:Full network access'
3030
'localhost:Localhost network only'
31-
'node:Node.js/npm toolchain'
32-
'python:Python toolchain'
3331
'rust:Rust/Cargo toolchain'
34-
'go:Go toolchain'
3532
'claude:Claude Code support'
3633
'gpg:GPG signing support'
37-
'git:Git with signing'
3834
)
3935

40-
local -a options
41-
options=(
42-
'--help:Show help'
43-
'--version:Show version'
44-
'--verbose:Verbose output'
45-
'--debug:Debug mode'
46-
'--trace:Trace sandbox violations'
47-
'--dry-run:Show profile without executing'
48-
'--explain:Show what would be allowed/denied'
49-
'--init:Initialize .sandbox.toml'
50-
'--offline:Block all network'
51-
'--online:Allow all network'
52-
'--localhost:Allow localhost only'
53-
)
54-
55-
_arguments \
36+
_arguments -s \
5637
'(-h --help)'{-h,--help}'[Show help]' \
5738
'(-V --version)'{-V,--version}'[Show version]' \
5839
'(-v --verbose)'{-v,--verbose}'[Verbose output]' \
5940
'(-d --debug)'{-d,--debug}'[Debug mode]' \
6041
'(-t --trace)'{-t,--trace}'[Trace violations]' \
42+
'--trace-file=[Write trace to file]:file:_files' \
6143
'(-n --dry-run)'{-n,--dry-run}'[Show profile]' \
44+
'(-c --config)'{-c,--config}'=[Use config file]:file:_files' \
45+
'--no-config[Ignore all config files]' \
6246
'--explain[Show permissions]' \
6347
'--init[Initialize config]' \
6448
'--offline[Block network]' \
6549
'--online[Allow network]' \
6650
'--localhost[Localhost only]' \
67-
'*:profile:_describe "profile" profiles' \
68-
'-- :command:_command_names'
51+
'*--allow-read=[Allow read access]:path:_files' \
52+
'*--allow-write=[Allow write access]:path:_files' \
53+
'*--deny-read=[Deny read access]:path:_files' \
54+
'*:: :->args'
55+
56+
case $state in
57+
args)
58+
if [[ ${words[CURRENT]} == -* ]]; then
59+
return
60+
fi
61+
# Check if we're past -- (command mode)
62+
local i
63+
for (( i=1; i < CURRENT; i++ )); do
64+
if [[ ${words[i]} == "--" ]]; then
65+
_command_names
66+
return
67+
fi
68+
done
69+
_describe -t profiles 'profile' profiles
70+
;;
71+
esac
6972
}
7073

7174
compdef _sx sx
7275

7376
# Aliases for common patterns
74-
alias sxo='sx online'
75-
alias sxl='sx localhost'
76-
alias sxn='sx online node'
77-
alias sxp='sx online python'
78-
alias sxr='sx online rust'
79-
alias sxc='sx gpg online claude'
77+
alias sxo='sx online' # Online network access
78+
alias sxl='sx localhost' # Localhost only
79+
alias sxr='sx online rust' # Rust with network
80+
alias sxc='sx online gpg claude' # Claude Code with GPG signing

0 commit comments

Comments
 (0)