various additions from sim laptop

This commit is contained in:
Alexander Gehrke 2025-05-08 13:55:52 +02:00 committed by Alexander Roso
parent 912a3282c5
commit 21e41141ef
13 changed files with 645 additions and 28 deletions

View file

@ -0,0 +1,33 @@
typeset -a chpwd_functions __chromaz_extra_left
export NVM_DIR="$HOME/.nvm"
nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm "$@"
}
_prompt_nvm_version() {
[[ -z $NVM_BIN ]] && return
echo "nvm: ${NVM_BIN:h:t}"
}
__chromaz_extra_left+=_prompt_nvm_version
find-nvmrc-version() {
local dir=${1:-${PWD:a}}
if [[ $dir == / ]]; then return 1; fi
if [[ -e $dir/.nvmrc ]]; then
< $dir/.nvmrc
else
find-nvmrc-version ${dir:h}
fi
}
chpwd-set-nvm() {
if vers=$(find-nvmrc-version); then
if [[ $vers != ${NVM_BIN:h:t} ]]; then
nvm use
fi
fi
}
chpwd-set-nvm &>/dev/null
chpwd_functions+=chpwd-set-nvm