Prevent from duplicated entries in PATH.

This commit is contained in:
Gea-Suan Lin
2023-04-07 21:45:07 +08:00
parent 26e16e9e52
commit 30c57e1038
4 changed files with 38 additions and 8 deletions

View File

@@ -11,7 +11,12 @@ alias "update=(cd ~/git; make all)"
#
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
if [[ ! "${PATH}" =~ "(^|:)${PYENV_ROOT}/bin(:|$)" ]]; then
export PATH="${PYENV_ROOT}/bin:${PATH}"
fi
if [[ ! "${PATH}" =~ "(^|:)${PYENV_ROOT}/shims(:|$)" ]]; then
export PATH="${PYENV_ROOT}/shims:${PATH}"
fi
eval "$(pyenv init - --no-rehash)"
fi
#
@@ -19,11 +24,15 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#
if [ -d "${HOME}/.rbenv" ]; then
export PATH="${HOME}/.rbenv/bin:${PATH}"
if [[ ! "${PATH}" =~ "(^|:)${HOME}/\\.rbenv/bin(:|$)" ]]; then
export PATH="${HOME}/.rbenv/bin:${PATH}"
fi
eval "$(rbenv init - --no-rehash)"
fi
#
if [ -d "${HOME}/.rvm" ]; then
export PATH="${HOME}/.rvm/bin:${PATH}"
if [[ ! "${PATH}" =~ "(^|:)${HOME}/\\.rvm/bin(:|$)" ]]; then
export PATH="${HOME}/.rvm/bin:${PATH}"
fi
source "${HOME}/.rvm/scripts/rvm"
fi