Copy clipboard history selection with Shift Return

This commit is contained in:
David Heinemeier Hansson
2026-05-29 13:15:00 +02:00
parent cf3a481224
commit bb0d9dd2e3
4 changed files with 66 additions and 5 deletions
+14 -2
View File
@@ -2,19 +2,31 @@
# omarchy:summary=Copy a file to the clipboard and paste it
# omarchy:group=clipboard
# omarchy:args=<mime-type> <path>
# omarchy:args=[--copy-only] <mime-type> <path>
# omarchy:examples=omarchy clipboard paste file image/png /tmp/screenshot.png
copy_only=false
if [[ ${1:-} == "--copy-only" ]]; then
copy_only=true
shift
fi
mime=${1:-}
path=${2:-}
if [[ -z $mime || -z $path ]]; then
echo "Usage: omarchy-clipboard-paste-file <mime-type> <path>" >&2
echo "Usage: omarchy-clipboard-paste-file [--copy-only] <mime-type> <path>" >&2
exit 1
fi
[[ -r $path ]] || exit 1
wl-copy --type "$mime" < "$path"
if [[ $copy_only == "true" ]]; then
exit
fi
sleep 0.15
wtype -M shift -k Insert -m shift 2>/dev/null || true
+13 -2
View File
@@ -2,10 +2,11 @@
# omarchy:summary=Copy text to the clipboard and type or paste it
# omarchy:group=clipboard
# omarchy:args=[--shift-insert] [--history-index <index>|<text>]
# omarchy:args=[--shift-insert] [--copy-only] [--history-index <index>|<text>]
# omarchy:examples=omarchy clipboard paste text "hello" | omarchy clipboard paste text --shift-insert "hello"
use_shift_insert=false
copy_only=false
history_index=""
text=""
@@ -15,6 +16,10 @@ while [[ $# -gt 0 ]]; do
use_shift_insert=true
shift
;;
--copy-only)
copy_only=true
shift
;;
--history-index)
history_index="${2:-}"
shift 2
@@ -35,13 +40,19 @@ copy_history_entry() {
if [[ -n $history_index ]]; then
copy_history_entry
use_shift_insert=true
if [[ $copy_only != "true" ]]; then
use_shift_insert=true
fi
else
text=${1:-}
[[ -n $text ]] || exit
printf '%s' "$text" | wl-copy
fi
if [[ $copy_only == "true" ]]; then
exit
fi
sleep 0.15
if [[ $use_shift_insert == "true" ]]; then