Skip to content

Commit

Permalink
add uv configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Zagatti committed Dec 5, 2024
1 parent 5fb33a5 commit 8441ef3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
11 changes: 11 additions & 0 deletions direnv/direnvrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ layout_pyenv() {
fi
fi
}

layout_uv() {
if [[ -d ".venv" ]]; then
local VIRTUAL_ENV="$(pwd)/.venv"
source "$VIRTUAL_ENV/bin/activate"
PATH_add "$VIRTUAL_ENV/bin"
export UV_ACTIVE=1
else
echo -e "\e[38:5:1mUV virtual environment not available.\e[0m"
fi
}
29 changes: 22 additions & 7 deletions shells/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,25 @@ if [[ $- == *i* ]]; then
# information about the current dev environment
_devenv_info() {
if hash $1 2>/dev/null; then
local venv=$($1 version-name)
if [ -n "$venv" ] && [ $venv != system ]; then
printf "$2 $venv"
fi
case "$1" in
pyenv|rbenv)
local venv=$($1 version-name)
if [ -n "$venv" ] && [ $venv != system ]; then
printf "$2 $venv"
fi
;;
uv)
if [ -n "$VIRTUAL_ENV" ] && [ -n "$VIRTUAL_ENV_PROMPT" ]; then
# local venv="${VIRTUAL_ENV_PROMPT#*(}"
local venv="${VIRTUAL_ENV_PROMPT%)*}"
venv="${venv#*\(}"
printf "py uv $venv"
fi
;;
*)
exit 1
;;
esac
fi
return
}
Expand Down Expand Up @@ -340,9 +355,9 @@ if [[ $- == *i* ]]; then
dev_info_msg="${dev_info_msg}nix-shell"
fi

local pyenv_info_msg=`_devenv_info pyenv py`
if [[ -n $pyenv_info_msg ]]; then
dev_info_msg="${dev_info_msg}${pyenv_info_msg}"
local uv_info_msg=`_devenv_info uv`
if [[ -n $uv_info_msg ]]; then
dev_info_msg="${dev_info_msg}${uv_info_msg}"
fi

local rbenv_info_msg=`_devenv_info rbenv rb`
Expand Down

0 comments on commit 8441ef3

Please sign in to comment.