Insert emojis without persisting clipboard entries
Keep the first emoji result selected whenever results exist, including after search filtering, so Enter inserts immediately. Route emoji insertion through a hidden helper that serves a transient sensitive clipboard entry long enough for Shift+Insert, then stops that clipboard owner. Mark transient emoji inserts so clipboard history skips only that event while continuing to record normal terminal copies.
This commit is contained in:
@@ -45,3 +45,47 @@ assertEqual(
|
||||
'emoji filtering finds face with tears of joy'
|
||||
)
|
||||
JS
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
mkdir -p "$TMPDIR/bin" "$TMPDIR/runtime"
|
||||
|
||||
cat >"$TMPDIR/bin/wl-copy" <<'SH'
|
||||
#!/bin/bash
|
||||
args="$*"
|
||||
target="$WL_COPY_OUT"
|
||||
if [[ $args == "--type text/plain --sensitive --foreground" ]]; then
|
||||
target="$WL_COPY_EMOJI_OUT"
|
||||
fi
|
||||
|
||||
printf '%s\n' "$args" >"$target.args"
|
||||
cat >"$target"
|
||||
SH
|
||||
|
||||
cat >"$TMPDIR/bin/wtype" <<'SH'
|
||||
#!/bin/bash
|
||||
printf '%s\n' "$*" >"$WTYPE_OUT"
|
||||
SH
|
||||
|
||||
cat >"$TMPDIR/bin/sleep" <<'SH'
|
||||
#!/bin/bash
|
||||
exit 0
|
||||
SH
|
||||
|
||||
chmod +x "$TMPDIR/bin/wl-copy" "$TMPDIR/bin/wtype" "$TMPDIR/bin/sleep"
|
||||
|
||||
WL_COPY_OUT="$TMPDIR/copy" WL_COPY_EMOJI_OUT="$TMPDIR/emoji" WTYPE_OUT="$TMPDIR/wtype" PATH="$TMPDIR/bin:$PATH" \
|
||||
XDG_RUNTIME_DIR="$TMPDIR/runtime" "$ROOT/bin/omarchy-menu-emoji-insert" "😀"
|
||||
|
||||
[[ $(<"$TMPDIR/emoji") == "😀" ]] || fail "emoji insert helper copies emoji transiently"
|
||||
pass "emoji insert helper copies emoji transiently"
|
||||
|
||||
[[ $(<"$TMPDIR/runtime/omarchy-emoji-insert-ignore") == "😀" ]] || fail "emoji insert helper marks transient emoji for history ignore"
|
||||
pass "emoji insert helper marks transient emoji for history ignore"
|
||||
|
||||
[[ $(<"$TMPDIR/emoji.args") == "--type text/plain --sensitive --foreground" ]] || fail "emoji insert helper serves transient clipboard in foreground"
|
||||
pass "emoji insert helper serves transient clipboard in foreground"
|
||||
|
||||
[[ $(<"$TMPDIR/wtype") == "-M shift -k Insert -m shift" ]] || fail "emoji insert helper pastes with shift insert"
|
||||
pass "emoji insert helper pastes with shift insert"
|
||||
|
||||
Reference in New Issue
Block a user