Skip to content

Commit 32ddc25

Browse files
authored
Merge pull request #10 from mmartinortiz/generate-completions-globally
Generate completions globally
2 parents 03e69b6 + 22bda1a commit 32ddc25

4 files changed

Lines changed: 7 additions & 36 deletions

File tree

src/uv/NOTES.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
11
## uv Repository
22

33
* [astral-sh/uv](https://github.com/astral-sh/uv)
4-
5-
## Fix Autocompletion with feature Shells
6-
7-
> [!IMPORTANT]
8-
> When installing a shell via another feature, make sure to override the installation order to ensure the generated autocompletion writes to existing files.
9-
10-
### Autocompletion for Fish Shell
11-
12-
```json
13-
"features": {
14-
"ghcr.io/meaningful-ooo/devcontainer-features/fish:latest": {},
15-
"ghcr.io/va-h/devcontainers-features/uv:latest": {
16-
"shellautocompletion": true
17-
}
18-
},
19-
"overrideFeatureInstallOrder": [
20-
"ghcr.io/meaningful-ooo/devcontainer-features/fish",
21-
"ghcr.io/va-h/devcontainers-features/uv:latest"
22-
]
23-
```

src/uv/install.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,9 @@ uv --version
156156

157157
enable_autocompletion() {
158158
command=$1
159-
if [ -f "$_REMOTE_USER_HOME/.bashrc" ]; then
160-
echo "eval \"\$(${command} bash)\"" >> $_REMOTE_USER_HOME/.bashrc
161-
fi
162-
if [ -f "$_REMOTE_USER_HOME/.zshrc" ]; then
163-
echo "eval \"\$(${command} zsh)\"" >> $_REMOTE_USER_HOME/.zshrc
164-
fi
165-
if [ -d "$_REMOTE_USER_HOME/.config/fish" ]; then
166-
mkdir -p $_REMOTE_USER_HOME/.config/fish/completions
167-
${command} fish >> $_REMOTE_USER_HOME/.config/fish/completions/uv.fish
168-
fi
169-
if [ -f "$_REMOTE_USER_HOME/.elvish/rc.elv" ]; then
170-
echo "eval (${command} elvish | slurp)" >> $_REMOTE_USER_HOME/.elvish/rc.elv
171-
fi
159+
${command} bash >> /usr/share/bash-completion/completions/uv
160+
${command} zsh >> /usr/share/zsh/vendor-completions/_uv
161+
${command} fish >> /usr/share/fish/completions/uv.fish
172162
}
173163

174164
if [ "$AUTOCOMPLETION" = "true" ]; then

test/uv/scenarios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
},
1010
"uv-autocomplete": {
11-
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
11+
"image": "mcr.microsoft.com/devcontainers/base:debian",
1212
"features": {
1313
"ghcr.io/devcontainers/features/common-utils:2.5.2": {
1414
"installZsh": true,

test/uv/uv-autocomplete.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ source dev-container-features-test-lib
99

1010
# Feature-specific tests
1111
# The 'check' command comes from the dev-container-features-test-lib.
12-
check "uv autocomplete bash" cat ~/.bashrc | grep "eval \"\$(uv" | grep bash
13-
check "uv autocomplete zsh" cat ~/.zshrc | grep "eval \"\$(uv" | grep zsh
12+
check "uv autocomplete bash" [ -e /usr/share/bash-completion/completions/uv ]
13+
check "uv autocomplete zsh" [ -e /usr/share/zsh/vendor-completions/_uv ]
14+
check "uv autocomplete fish" [ -e /usr/share/fish/completions/uv.fish ]
1415

1516
# Report results
1617
# If any of the checks above exited with a non-zero exit code, the test will fail.

0 commit comments

Comments
 (0)