diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-11-24 19:12:51 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-11-24 19:12:51 +0100 |
commit | 3a21f592504009226421f28245ae9be4b7ba0978 (patch) | |
tree | 5fc5dc7051ae7f534f10d936a9b0f5d6a1c5b34f /bash/10-env.profile | |
parent | 07a5b751ee419f543f43c181cc2bbc4b00bb4d32 (diff) | |
download | dotfiles-3a21f592504009226421f28245ae9be4b7ba0978.tar.gz |
fix path control
Diffstat (limited to 'bash/10-env.profile')
-rw-r--r-- | bash/10-env.profile | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/bash/10-env.profile b/bash/10-env.profile index 10a1b59..a3decae 100644 --- a/bash/10-env.profile +++ b/bash/10-env.profile @@ -1,9 +1,19 @@ # vi:filetype=sh +function is_not_in_path() { + local regex="(:|^)${1//'/'/'\/*'}(:|$)" + [[ ! ${PATH} =~ $regex ]] +} + function appendpath() { - local regex="[:^]${1//'/'/'\/'}[:$]" - if [[ ! ${PATH} =~ $regex ]]; then - PATH=$PATH:$1 + if is_not_in_path "$1"; then + PATH="$PATH:$1" + fi +} + +function prependpath() { + if is_not_in_path "$1"; then + PATH="$1:$PATH" fi } @@ -12,10 +22,9 @@ appendpath "$DOTFILEBASE/scripts" appendpath "$HOME/.local/bin" appendpath "$HOME/go/bin" appendpath "$HOME/.cabal/bin" -appendpath "$HOME/.ghcup/bin" +prependpath "$HOME/.ghcup/bin" export PATH -unset appendpath if which nvim > /dev/null 2>&1 && [ ! "$FORCE_VANILLA_VIM" = "yes" ] ; then export EDITOR=nvim |