Last active
January 20, 2025 17:11
-
-
Save dougpagani/b2abb1b8aea0e4af9ce3271c2ecbbe91 to your computer and use it in GitHub Desktop.
Dylan's Espanso script, before and after
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
#!/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 |
I meant send this to stderr********************************, with >&2
ahh gotcha thx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dougpagani
Is this just good script hygiene to be explicit? I thought echo sends to stdout when you don't redirect output.