uv.plugin.zsh 1.2 KB

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