summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sh/profile79
1 files changed, 32 insertions, 47 deletions
diff --git a/sh/profile b/sh/profile
index c9c2ca8..0979aa4 100644
--- a/sh/profile
+++ b/sh/profile
@@ -78,55 +78,40 @@ export BLENDER_3_0="/usr/bin/blender"
export SRCDIR="$HOME/.local/src"
# OLD PATH
-export SYSPATH="$PATH"
+export PATHS="$(echo "$PATH" | sed 's/:/\n/g')"
+USERPATH=""
+
+addtopath () {
+ local USERPATHS="$(echo "$USERPATH" | sed 's/:/\n/g')"
+ if [ -d "$1" ]; then
+ echo "$PATHS" | /usr/bin/grep -qE "^$1$" && return
+ echo "$USERPATHS" | /usr/bin/grep -qE "^$1$" && return
+ [ -n "$USERPATH" ] && USERPATH="${USERPATH}:"
+ USERPATH="${USERPATH}$1"
+ fi
+}
# NEW PATH
-unset PATH
-if [ -d "$HOME/.local/bin/testing" ]; then
- PATH="$HOME/.local/bin/testing"
-fi
-if [ -d "$HOME/.local/bin/shortcmds" ]; then
- PATH="$PATH:$HOME/.local/bin/shortcmds"
-fi
-if [ -d "$HOME/.local/bin/generics" ]; then
- PATH="$PATH:$HOME/.local/bin/generics"
-fi
-if [ -d "$HOME/.local/bin/scripts" ]; then
- PATH="$PATH:$HOME/.local/bin/scripts"
-fi
-if [ -d "$HOME/.local/bin/sp" ]; then
- PATH="$PATH:$HOME/.local/bin/sp"
-fi
-if [ -d "$HOME/.local/bin/blocks" ]; then
- PATH="$PATH:$HOME/.local/bin/blocks"
-fi
-if [ -d "$HOME/.local/bin/ignore" ]; then
- PATH="$PATH:$HOME/.local/bin/ignore"
-fi
-if [ -d "$HOME/.local/bin/volsv" ]; then
- PATH="$PATH:$HOME/.local/bin/volsv"
-fi
-if [ -d "$HOME/.local/bin" ]; then
- PATH="$PATH:$HOME/.local/bin"
-fi
-if [ -d "$HOME/.local/bin/flatpak-sc" ]; then
- PATH="$PATH:$HOME/.local/bin/flatpak-sc"
-fi
-if [ -d "$HOME/.local/bin/flatpak/exports/bin" ]; then
- PATH="$PATH:$HOME/.local/share/flatpak/exports/bin/"
-fi
-if [ -d "$CARGO_HOME/bin" ]; then
- PATH="$PATH:$CARGO_HOME/bin"
-fi
-if [ -d "$GOPATH/bin" ]; then
- PATH="$PATH:$GOPATH/bin"
-fi
-if [ -d "/var/lib/flatpak/exports/bin" ]; then
- PATH="$PATH:/var/lib/flatpak/exports/bin"
-fi
+addtopath "$HOME/.local/bin/testing"
+addtopath "$HOME/.local/bin/shortcmds"
+addtopath "$HOME/.local/bin/generics"
+addtopath "$HOME/.local/bin/scripts"
+addtopath "$HOME/.local/bin/sp"
+addtopath "$HOME/.local/bin/blocks"
+addtopath "$HOME/.local/bin/ignore"
+addtopath "$HOME/.local/bin/volsv"
+addtopath "$HOME/.local/bin"
+addtopath "$HOME/.local/bin/flatpak-sc"
+addtopath "$HOME/.local/share/flatpak/exports/bin/"
+addtopath "$CARGO_HOME/bin"
+addtopath "$GOPATH/bin"
+addtopath "$ZVMPATH"
+addtopath "$ZVM_INSTALL"
+addtopath "/var/lib/flatpak/exports/bin"
# MERGE PATHS
-export PATH="$PATH:$SYSPATH"
+[ -n "$USERPATH" ] && export PATH="$USERPATH:$PATH"
-# CLEANUP
-unset SYSPATH
+unset -f addtopath
+unset USERPATH
+unset PATHS