aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2024-04-16 11:18:53 -0400
committerRyan Kavanagh <rak@rak.ac>2024-04-16 11:18:53 -0400
commitdb9d1b77179e4d1f0ba6ba2606879a3dfd20f9b5 (patch)
tree13d9c92c9369f6f4120510977ec8f247be4a46f6
parentdrop packages-debian (diff)
smarter PATH setting
-rw-r--r--dot_config/environment.d/01_PATH.conf19
1 files changed, 16 insertions, 3 deletions
diff --git a/dot_config/environment.d/01_PATH.conf b/dot_config/environment.d/01_PATH.conf
index e342e30..104fba4 100644
--- a/dot_config/environment.d/01_PATH.conf
+++ b/dot_config/environment.d/01_PATH.conf
@@ -1,3 +1,16 @@
-PATH=${PATH:-/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games}
-PATH=${HOME}/.cargo/bin:${PATH}
-PATH=${HOME}/bin:${PATH}
+PATH="${PATH:-/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games}"
+for dir in \
+ "/usr/games" \
+ "/usr/sbin" \
+ "/sbin" \
+ "${HOME}/.cabal/bin" \
+ "${HOME}/.cargo/bin" \
+ "${HOME}/bin"; do
+ case :$PATH: in
+ *:${dir}:*)
+ # ${dir} already in PATH
+ ;;
+ *)
+ PATH="${dir}:${PATH}";;
+ esac
+done