From 6e0079a66d97a50e0c9a525b7d9422ebce8820e3 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Wed, 20 May 2026 19:55:14 -0400 Subject: [PATCH] omarchy-dev-link/unlink: strip prior dev-link bin/ from PATH Sequential 'dev-link A' then 'dev-link B' previously left A/bin in PATH because the prepend didn't strip the old one. unlink had the same issue (it was trying to strip $(dirname $0), which only worked if you invoked unlink via an absolute path that happened to match the dev-link bin). Both now read the previous OMARCHY_PATH from /etc/omarchy.conf before overwriting/deleting it, and strip that path's bin/ from PATH before prepending the new one (or nothing, for unlink). --- bin/omarchy-dev-link | 10 ++++++++++ bin/omarchy-dev-unlink | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) 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