Created
October 11, 2016 04:17
-
-
Save azenla/4c061463f3688222d512741f438c5418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
DISCORDS="$(xdotool search "Discord" | tail -n 1)" | |
CONTENT="$(cat - | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | sed '0~20 a\``````\')" | |
if [ "${CONTENT: -6}" == '``````' ] | |
then | |
CONTENT="${CONTENT::-3}" | |
fi | |
if [ -z "${DISCORDS}" ] | |
then | |
echo "Discord window was not found." | |
exit 1 | |
fi | |
for W in ${DISCORDS} | |
do | |
xdotool windowactivate ${W} | |
xdotool key --window ${W} Tab | |
xdotool type --window ${W} '```' | |
xdotool type --window ${W} "${CONTENT}" | |
[ "${CONTENT: -3}" != '```' ] && xdotool type --window ${W} '```' | |
xdotool key --window ${W} KP_Enter | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment