2
0

uv.plugin.zsh 1.1 KB

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