From 0aab087f1177495fe9429b75fa419c50924a9135 Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 6 May 2026 03:44:20 +0200 Subject: [PATCH] Zsh: Added widgets for mkcd and improved uv init --- .config/zsh/.zshrc | 35 ++++++++++++++++++++++++++++++----- .profile | 12 ------------ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index fa12e8e..f711a59 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -85,12 +85,40 @@ function +vi-git-stash() { # CUSTOM WIDGETS # ################## +mkcd() { + mkdir -p -- "$1" && + cd -- "$1" +} + +uv() { + if [[ "$1" == "init" ]]; then + shift + + if [[ "$1" == "--normal" ]]; then + shift + command uv init "$@" + else + command uv init --bare "$@" || return + + if [[ $# -eq 0 ]]; then + command uv venv || return + + if [[ -f ".venv/bin/activate" ]]; then + source .venv/bin/activate + fi + fi + fi + else + command uv "$@" + fi +} + _find_venv_upwards() { local dir="$PWD" while [[ "$dir" != "/" ]]; do - if [[ -f "$dir/pyvenv.cfg" ]]; then - echo "$dir" + if [[ -f "$dir/.venv/pyvenv.cfg" ]]; then + echo "$dir/.venv" return fi dir=$(dirname "$dir") @@ -314,9 +342,6 @@ fi # thefuck eval $(thefuck --alias) -# python -eval "$(pyenv init -)" - # opam [[ ! -r "$HOME/.opam/opam-init/init.zsh" ]] || source "$HOME/.opam/opam-init/init.zsh" > /dev/null 2> /dev/null diff --git a/.profile b/.profile index 6b2c1cc..74abe1e 100644 --- a/.profile +++ b/.profile @@ -72,18 +72,6 @@ export VIPER_CARBON="" export VIPER_Z3="/bin/z3" export VIPER_BOOGIE="$HOME/.dotnet/tools/boogie" -# python -export PYENV_ROOT="$HOME/.pyenv" - -if [ -d "$PYENV_ROOT" ] && [ -x "PYENV_ROOT/bin/pyenv" ]; then - export PATH="$PYENV_ROOT/bin:$PATH" - if command -v timeout >/DEV/NULL 2>&1; then - timeout 2s -c sh -c 'eval "$($PYENV_ROOT/bin/pyenv init --path)"' 2>/dev/null - else - eval "$($PYENV_ROOT/bin/pyenv init --path 2>/dev/null)" || true - fi -fi - # less/man colors export LESS=-R export LESS_TERMCAP_mb="$(printf '%b' '')"; a="${a%_}"