Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save jyc/910731e79730a55244b3e9563af85cf8 to your computer and use it in GitHub Desktop.
#!/bin/zsh
set -euo pipefail
typeset -a SNIPPETS
SNIPPETS=(
note 🗒
pin 📌
stopwatch ⏱
)
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
echo "Nothing selected."
exit 1
fi
echo -n "$snippet" | xclip
xdotool click 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment