uv.plugin.zsh
1389 bytes
1# Return immediately if uv is not found
2if (( ! ${+commands[uv]} )); then
3 return
4fi
5
6alias uv="noglob uv"
7
8alias uva='uv add'
9alias uvexp='uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet'
10alias uvi='uv init'
11alias uvinw='uv init --no-workspace'
12alias uvl='uv lock'
13alias uvlr='uv lock --refresh'
14alias uvlu='uv lock --upgrade'
15alias uvp='uv pip'
16alias uvpi='uv python install'
17alias uvpl='uv python list'
18alias uvpu='uv python uninstall'
19alias uvpy='uv python'
20alias uvpp='uv python pin'
21alias uvr='uv run'
22alias uvrm='uv remove'
23alias uvs='uv sync'
24alias uvsr='uv sync --refresh'
25alias uvsu='uv sync --upgrade'
26alias uvtr='uv tree'
27alias uvup='uv self update'
28alias uvv='uv venv'
29
30# If the completion file doesn't exist yet, we need to autoload it and
31# bind it. Otherwise, compinit will have already done that.
32if [[ ! -f "$ZSH_CACHE_DIR/completions/_uv" ]]; then
33 typeset -g -A _comps
34 autoload -Uz _uv
35 _comps[uv]=_uv
36fi
37
38if [[ ! -f "$ZSH_CACHE_DIR/completions/_uvx" ]]; then
39 typeset -g -A _comps
40 autoload -Uz _uvx
41 _comps[uvx]=_uvx
42fi
43
44# uv and uvx are installed together (uvx is an alias to `uv tool run`)
45# Overwrites the file each time as completions might change with uv versions.
46uv generate-shell-completion zsh >| "$ZSH_CACHE_DIR/completions/_uv" &|
47uvx --generate-shell-completion zsh >| "$ZSH_CACHE_DIR/completions/_uvx" &|