Skip to content

Instantly share code, notes, and snippets.

@dougpagani
Last active March 4, 2022 01:54
Show Gist options
  • Save dougpagani/b2abb1b8aea0e4af9ce3271c2ecbbe91 to your computer and use it in GitHub Desktop.
Save dougpagani/b2abb1b8aea0e4af9ce3271c2ecbbe91 to your computer and use it in GitHub Desktop.
Dylan's Espanso script, before and after
#!/bin/bash
FORM_OUTPUT=$(zenity --forms \
--add-entry "trigger:" \
--add-entry "replacement:" \
--add-combo "word:" --combo-values="false|true" \
--add-combo "propagate case:" --combo-values="true|false")
TRIGGER=$(echo $FORM_OUTPUT | cut -d "|" -f1 | tr -d '[:space:]')
REPLACE=$(echo $FORM_OUTPUT | cut -d "|" -f2 | tr -d '[:space:]')
WORD=$(echo $FORM_OUTPUT | cut -d "|" -f3 | tr -d '[:space:]')
PROPAGATE_CASE=$(echo $FORM_OUTPUT | cut -d "|" -f4 | tr -d '[:space:]')
FILE="/home/dylan/.config/espanso/default.yml"
if [[ "$TRIGGER" = "" || "$REPLACE" = "" ]]; then
echo "Trigger and Replace are required fields"
exit 1
else
printf "
- trigger: \"$TRIGGER\"
replace: \"$REPLACE\"
word: ${WORD:-"false"}
propagate_case: ${PROPAGATE_CASE:-"true"}
" >> $FILE
fi
echo $REPLACE
#!/bin/bash
FORM_OUTPUT=$(zenity --forms \
--add-entry "trigger:" \
--add-entry "replacement:" \
--add-combo "word:" --combo-values="false|true" \
--add-combo "propagate case:" --combo-values="true|false")
TRIGGER=$(echo $FORM_OUTPUT | cut -d "|" -f1 | tr -d '[:space:]')
REPLACE=$(echo $FORM_OUTPUT | cut -d "|" -f2 | tr -d '[:space:]')
WORD=$(echo $FORM_OUTPUT | cut -d "|" -f3 | tr -d '[:space:]')
PROPAGATE_CASE=$(echo $FORM_OUTPUT | cut -d "|" -f4 | tr -d '[:space:]')
if [[ "$WORD" = "" ]]; then
WORD="false"
fi
if [[ "$PROPAGATE_CASE" = "" ]]; then
PROPAGATE_CASE="true"
fi
FILE="/home/dylan/.config/espanso/default.yml"
if [[ "$TRIGGER" = "" || "$REPLACE" = "" ]]; then
echo "Trigger and Replace are required fields"
exit 1
else
printf "
- trigger: \"$TRIGGER\"
replace: \"$REPLACE\"
word: $WORD
propagate_case: $PROPAGATE_CASE
" >> $FILE
fi
echo $REPLACE
@dougpagani
Copy link
Author

I meant send this to stderr********************************, with >&2

@dougpagani
Copy link
Author

@dylan-sessler
Copy link

ahh gotcha thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment