diff --git a/bin/omarchy-dev-link b/bin/omarchy-dev-link index 0f779d52..091c8a4a 100755 --- a/bin/omarchy-dev-link +++ b/bin/omarchy-dev-link @@ -42,10 +42,20 @@ for required in bin default shell; do fi done +# Strip any previous dev-link's bin/ from PATH before adding the new one, +# so repeated link calls don't accumulate stale entries. +prior_target="" +if [[ -f /etc/omarchy.conf ]]; then + prior_target=$(sed -n 's/^[[:space:]]*export[[:space:]]\+OMARCHY_PATH="\?\([^"]*\)"\?/\1/p' /etc/omarchy.conf | tail -1) +fi + echo "Pointing Omarchy at $target" printf 'export OMARCHY_PATH="%s"\n' "$target" | sudo tee /etc/omarchy.conf >/dev/null export OMARCHY_PATH="$target" +if [[ -n $prior_target && $prior_target != "$target" ]]; then + PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vFx "$prior_target/bin" | paste -sd:) +fi export PATH="$target/bin:$PATH" if command -v hyprctl >/dev/null 2>&1 && hyprctl version &>/dev/null; then diff --git a/bin/omarchy-dev-unlink b/bin/omarchy-dev-unlink index 8f00a784..cbd9f828 100755 --- a/bin/omarchy-dev-unlink +++ b/bin/omarchy-dev-unlink @@ -26,13 +26,17 @@ if [[ ! -f /etc/omarchy.conf ]]; then exit 0 fi +# Capture the path dev-link wrote BEFORE we delete the conf, so we know +# which bin/ to strip from PATH. +prior_target=$(sed -n 's/^[[:space:]]*export[[:space:]]\+OMARCHY_PATH="\?\([^"]*\)"\?/\1/p' /etc/omarchy.conf | tail -1) sudo rm -f /etc/omarchy.conf echo "Removed /etc/omarchy.conf" export OMARCHY_PATH=/usr/share/omarchy -# Drop the checkout bin/ that dev-link prepended. -PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vFx "$(dirname "$0")" | paste -sd:) -export PATH +if [[ -n $prior_target ]]; then + PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vFx "$prior_target/bin" | paste -sd:) + export PATH +fi if command -v hyprctl >/dev/null 2>&1 && hyprctl version &>/dev/null; then hyprctl setenv OMARCHY_PATH /usr/share/omarchy >/dev/null