Skip to content

Instantly share code, notes, and snippets.

@jyc
Created August 4, 2017 05:39
Show Gist options
  • Select an option

  • Save jyc/c664ec0c96d17f411164e759c626b77f to your computer and use it in GitHub Desktop.

Select an option

Save jyc/c664ec0c96d17f411164e759c626b77f to your computer and use it in GitHub Desktop.
#!/bin/zsh
set -euo pipefail
typeset -a SNIPPETS
SNIPPETS=(
note πŸ—’
pin πŸ“Œ
stopwatch ⏱
fire πŸ”₯
sushi 🍣
broken-heart πŸ’”
)
local text=$(
for ((i = 1; i <= ${#SNIPPETS}; i = i + 2)); do
echo ${SNIPPETS[$i]}
done | dmenu
)
local snippet=$(
for ((i = 1; i <= ${#SNIPPETS}; i = i + 2)); do
if [[ "${SNIPPETS[$i]}" == $text ]]; then
echo ${SNIPPETS[$i + 1]}
fi
done
)
if [[ -z "$snippet" ]]; then
notify-send "Didn't recognize text '$text'."
exit 1
fi
echo -n "$snippet" | xclip
#echo -n "$snippet" | iconv -f UTF8 -t UTF16 | xvkbd -utf -file -
# Send a middle click. Can be wrong sometimes.
#xdotool click 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment