Skip to content

Commit 0a40dd6

Browse files
committed
shell completion installation
Signed-off-by: Connor Braa <[email protected]>
1 parent ac76bf2 commit 0a40dd6

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

.goreleaser.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ project_name: container-use
66
before:
77
hooks:
88
- go mod tidy
9+
- ./scripts/completions.sh
910

1011
builds:
1112
- id: cu
@@ -34,6 +35,7 @@ archives:
3435
files:
3536
- README.md
3637
- LICENSE
38+
- completions/*
3739

3840
homebrew_casks:
3941
- repository:
@@ -53,9 +55,14 @@ homebrew_casks:
5355
template: "https://github.com/{{ .Env.GH_ORG_NAME }}/container-use/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
5456
homepage: "https://github.com/{{ .Env.GH_ORG_NAME }}/container-use"
5557
description: "Containerized environments for coding agents"
58+
completions:
59+
bash: "completions/cu.bash"
60+
zsh: "completions/cu.zsh"
61+
fish: "completions/cu.fish"
5662
hooks:
5763
post:
5864
install: |
65+
# remove quarantine xattr (note we don't do anything with signatures yet)
5966
if system_command("/usr/bin/xattr", args: ["-h"]).exit_status == 0
6067
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/cu"]
6168
end

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,21 @@ It's an open-source MCP server that works as a CLI tool with Claude Code, Cursor
3535

3636
## Install
3737

38-
### macOS (Homebrew - Recommended)
38+
### Homebrew (Recommended for MacOS)
3939

4040
```sh
4141
brew install dagger/tap/container-use
4242
```
4343

44-
(Optional) Install shell completions:
45-
46-
```sh
47-
cu completion bash > $(brew --prefix)/etc/bash_completion.d/container-use
48-
```
44+
Our tap should install shell completions for you.
4945

5046
### All Platforms (Shell Script)
5147

5248
```sh
5349
curl -fsSL https://raw.githubusercontent.com/dagger/container-use/main/install.sh | bash
5450
```
5551

56-
This will check for Docker & Git (required), detect your platform, and install the latest `cu` binary to your `$PATH`.
57-
58-
(Optional) Install shell completions:
59-
60-
```sh
61-
cu completion bash > /etc/bash_completion.d/container-use
62-
```
52+
This will check for Docker & Git (required), detect your platform, install the latest `cu` binary to your `$PATH`, and provide completion installation instructions.
6353

6454
For building from source, see [CONTRIBUTING.md](CONTRIBUTING.md#building).
6555

install.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ get_latest_version() {
127127
curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
128128
}
129129

130+
# Show shell completion setup instructions
131+
show_completion_instructions() {
132+
local binary="$1"
133+
134+
log_info "To enable shell completions, run:"
135+
echo " Bash (with bash-completion): $binary completion bash > ~/.local/share/bash-completion/completions/cu"
136+
echo " Bash (unconfigured): echo 'source <($binary completion bash)' >> ~/.bashrc"
137+
echo " Zsh (with compinit and a writable fpath[1]): $binary completion zsh > \"\${fpath[1]}/_cu\""
138+
echo " Zsh (unconfigured): echo 'source <($binary completion bash)' >> ~/.zshrc"
139+
echo " Fish: $binary completion fish > ~/.config/fish/completions/cu.fish"
140+
}
141+
130142
# Verify checksum of downloaded file
131143
verify_checksum() {
132144
local archive_file="$1"
@@ -281,6 +293,9 @@ main() {
281293
if [ -x "$INSTALL_DIR/$BINARY_NAME" ]; then
282294
log_success "Installation complete!"
283295

296+
# Show shell completion instructions
297+
show_completion_instructions "$BINARY_NAME"
298+
284299
# Check if the correct cu command is being found in PATH
285300
local found_binary=$(command -v "$BINARY_NAME" 2>/dev/null || echo "")
286301

scripts/completions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
rm -rf completions
4+
mkdir completions
5+
for sh in bash zsh fish; do
6+
go run ./cmd/cu completion "$sh" >"completions/cu.$sh"
7+
done

0 commit comments

Comments
 (0)