fix: add directories to PATH only if not present already

This commit is contained in:
Dan Anglin 2022-05-02 15:59:54 +01:00
parent 44a6ca8350
commit 64f2783270
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
3 changed files with 14 additions and 3 deletions

View file

@ -2,10 +2,15 @@
[[ $- != *i* ]] && return
# == Add personal bin directory to PATH
if [ -d ${HOME}/.local/bin ]; then
if ! [[ "${PATH}" =~ "${HOME}/.local/bin" ]]; then
export PATH=${HOME}/.local/bin:${PATH}
fi
# == Add custom scripts directory to PATH
if ! [[ "${PATH}" =~ "${HOME}/.local/scripts" ]]; then
export PATH=${HOME}/.local/scripts:${PATH}
fi
export XDG_CONFIG_HOME=${HOME}/.local/config
export XDG_DATA_HOME=${HOME}/.local/share
export XDG_CACHE_HOME=${HOME}/.local/cache

View file

@ -5,7 +5,10 @@ if [ -f "${HOME}/.local/software/go/bin/go" ]; then
export GOPATH=${XDG_DATA_HOME}/go
export GOROOT=${HOME}/.local/software/go
export GOBIN=${HOME}/.local/goblin
export PATH=${PATH}:${GOBIN}
if ! [[ "${PATH}" =~ "${GOBIN}" ]]; then
export PATH=${GOBIN}:${PATH}
fi
if ! [ -d "${GOPATH}" ]; then
mkdir ${GOPATH}

View file

@ -2,8 +2,11 @@ if [[ -d "$HOME/.local/software" ]]; then
for dir in ${HOME}/.local/software/*; do
dir=${dir:A}
if [[ -d "$dir/bin" ]]; then
export PATH="$dir/bin:$PATH"
if ! [[ "${PATH}" =~ "$dir/bin" ]]; then
export PATH="$dir/bin:$PATH"
fi
fi
done
fi
unset dir