Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/omarchy-plugin-clone
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ Copies a built-in plugin into ~/.config/omarchy/plugins/<username>.<id>/ so you
can edit it freely. The clone keeps all of the source plugin's files and kinds
and uses "My <name>" as its display name, then replaces the built-in with the
clone. The username prefix keeps the id yours, so a shared clone does not
collide with anyone else's. --edit opens the clone in \$EDITOR afterwards.
collide with anyone else's, except that a username which would land the clone in
the reserved omarchy. namespace gets the shared local.<id> instead. --edit opens
the clone in \$EDITOR afterwards.

USAGE
}
Expand Down Expand Up @@ -129,6 +131,10 @@ source_info=$(omarchy-plugin-catalog | jq -r --arg id "$source_id" '
IFS=$'\t' read -r source_dir source_manifest source_name <<<"$source_info"

new_id="${USER:-$(id -un)}.${source_id#omarchy.}"
# A user named omarchy would put the clone back in the omarchy. namespace the shell reserves for built-ins.
if [[ $new_id == omarchy.* ]]; then
new_id="local.${source_id#omarchy.}"
fi
display_name="My $source_name"
target_dir="$PLUGINS_DIR/$new_id"
[[ ! -e $target_dir && ! -L $target_dir ]] || fail "$target_dir already exists"
Expand Down
16 changes: 15 additions & 1 deletion test/shell.d/plugin-clone-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ clone_plugin() {
}
}
}'
HOME="$TMPDIR/home" USER=tester OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \
HOME="$TMPDIR/home" USER="${CLONE_USER:-tester}" OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \
FAKE_CALLS="$CALLS" OMARCHY_TEST_ROOT="$ROOT" \
FAKE_SHELL_CONFIG="${FAKE_CLONE_CONFIG:-$default_config}" \
omarchy-plugin-clone "$@"
Expand Down Expand Up @@ -173,6 +173,20 @@ fi
fail "rejected custom id leaves a clone behind"
pass "clone derives the personal id from the username"

for user in omarchy omarchy.dev; do
: >"$CALLS"
CLONE_USER=$user clone_plugin omarchy.weather >/dev/null
[[ ! -e $TMPDIR/home/.config/omarchy/plugins/$user.weather ]] ||
fail "user $user clones into the reserved omarchy namespace"
jq -e '.id == "local.weather" and .omarchy.clonedFrom == "omarchy.weather"' \
"$TMPDIR/home/.config/omarchy/plugins/local.weather/manifest.json" >/dev/null ||
fail "user $user does not get a local clone id"
grep -qx 'omarchy-plugin-enable local.weather' "$CALLS" ||
fail "user $user does not get the clone enabled"
rm -rf "$TMPDIR/home/.config/omarchy/plugins/local.weather"
done
pass "a username in the omarchy namespace clones outside it"

if clone_plugin omarchy.weather --replace >/dev/null 2>&1; then
fail "clone still accepts bar layout actions"
fi
Expand Down