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).
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user