aboutsummaryrefslogtreecommitdiff
path: root/exports
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2022-11-05 17:33:42 +0100
committerBond_009 <bond.009@outlook.com>2022-11-05 17:33:42 +0100
commit0be806da1ce6b5869da3021f61ae3decc7b16602 (patch)
tree04aaddfc9289d9afa8bcb1dae6a78623e7e27303 /exports
parentd1d6eb28017b7254f0a20a5177fc9742f2f4f139 (diff)
Remove duplicates from PATH
Diffstat (limited to 'exports')
-rw-r--r--exports/.exports35
1 files changed, 27 insertions, 8 deletions
diff --git a/exports/.exports b/exports/.exports
index 55c1e8b..6737695 100644
--- a/exports/.exports
+++ b/exports/.exports
@@ -1,13 +1,29 @@
#!/bin/sh
# PATH
-## Set PATH so it includes user's private bin, cargos bin and dotnet if they exist
-[ -d "$HOME/bin" ] && export PATH="$HOME/bin:$PATH"
-[ -d "$HOME/.local/bin" ] && export PATH="$HOME/.local/bin:$PATH"
-[ -d "$HOME/.cargo/bin" ] && export PATH="$HOME/.cargo/bin:$PATH"
-[ -d "$HOME/dotnet" ] && export PATH="$HOME/dotnet:$PATH" && export DOTNET_ROOT="$HOME/dotnet"
-[ -d "$HOME/.dotnet/tools" ] && export PATH="$HOME/.dotnet/tools:$PATH"
-[ -d "$HOME/pico/pico-sdk" ] && export PICO_SDK_PATH="$HOME/pico/pico-sdk"
+pathmunge () {
+ case ":${PATH}:" in
+ *:"$1":*)
+ ;;
+ *)
+ if [ "$2" = "after" ]; then
+ PATH="$PATH:$1"
+ else
+ PATH="$1:$PATH"
+ fi
+ esac
+}
+
+## Set PATH so it includes user's private bin, cross compilers, cargos bin and dotnet if they exist
+[ -d "$HOME/bin" ] && pathmunge "$HOME/bin"
+[ -d "$HOME/.local/bin" ] && pathmunge "$HOME/.local/bin"
+[ -d "$HOME/opt/cross/bin" ] && pathmunge "$HOME/opt/cross/bin"
+[ -d "$HOME/.cargo/bin" ] && pathmunge "$HOME/.cargo/bin"
+[ -d "$HOME/dotnet" ] && pathmunge "$HOME/dotnet" && export DOTNET_ROOT="$HOME/dotnet"
+[ -d "$HOME/.dotnet/tools" ] && pathmunge "$HOME/.dotnet/tools"
+
+# Force PATH to be environment
+export PATH
# Colors for BSD tools
export CLICOLOR=1
@@ -34,5 +50,8 @@ fi
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1
-# RUST
+# Rust
export RUST_BACKTRACE=1
+
+# Pico SDK
+[ -d "$HOME/pico/pico-sdk" ] && export PICO_SDK_PATH="$HOME/pico/pico-sdk"