diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-07-02 11:04:41 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-07-02 11:04:41 -0500 |
commit | 48f3c0166a627340bc287179c6ab4b02d689f9e6 (patch) | |
tree | 9aff0af364a7dfc25a2531ed451b9d7b409d7518 /sh/.profile | |
parent | e0bd7e033d384d162f937b823f6d12d0de8f6d0d (diff) |
fix: prepend path to allow for command overriding
Diffstat (limited to 'sh/.profile')
-rw-r--r-- | sh/.profile | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sh/.profile b/sh/.profile index 2b794d7..0b1d175 100644 --- a/sh/.profile +++ b/sh/.profile @@ -3,13 +3,13 @@ # Most of this script is a user scoped version of /etc/profile -# Append "$1" to $PATH when not already in. +# Prepend "$1" to $PATH when not already in. # This function API is accessible to scripts in $XDG_CONFIG_HOME/profile.d -append_path() { +prepend_path() { case ":$PATH:" in *:"$1":*) ;; *) - PATH="${PATH:+$PATH:}$1" + PATH="$1${PATH:+:$PATH}" ;; esac } @@ -21,11 +21,6 @@ for generator in /usr/lib/systemd/user-environment-generators/*; do export $($generator | xargs) done -append_path "$HOME/.local/bin" - -# Force PATH to be environment -export PATH - # Load profiles from $XDG_CONFIG_HOME/profile.d if test -d "$XDG_CONFIG_HOME"/profile.d/; then for profile in "$XDG_CONFIG_HOME"/profile.d/*.sh; do @@ -34,5 +29,10 @@ if test -d "$XDG_CONFIG_HOME"/profile.d/; then unset profile fi +prepend_path "$HOME/.local/bin" + +# Force PATH to be environment +export PATH + # Unload our profile API functions unset -f append_path |