diff --git a/scripts/cecho b/scripts/cecho index dde03f4..50b76c1 100755 --- a/scripts/cecho +++ b/scripts/cecho @@ -74,16 +74,10 @@ function cecho(){ On_ICyan='\033[0;106m' # Cyan On_IWhite='\033[0;107m' # White - #RED="\033[0;31m" - #GREEN="\033[0;32m" # <-- [0 means not bold - #YELLOW="\033[1;33m" # <-- [1 means bold - #CYAN="\033[1;36m" - # ... Add more colors if you like - NC="\033[0m" # No Color # printf "${(P)1}${2} ${NC}\n" # <-- zsh - printf "${!1}${!2}${3} ${NC}\n" # <-- bash + printf "${!1}${!2}${3}${NC}\n" # <-- bash } if [ -z "$1" ] diff --git a/scripts/dictionary b/scripts/dictionary new file mode 100755 index 0000000..3046cdd --- /dev/null +++ b/scripts/dictionary @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +mkdir -p "${HOME}"/.local/tmp + +searchterm=$(zenity --entry --text "Enter word to define" --title "Dictionary" 2> /dev/null); +dict -h localhost -d gcide "${searchterm}" > "${HOME}"/.local/tmp/"${searchterm}".txt 2>&1 + +content=$(cat "${HOME}"/.local/tmp/"${searchterm}".txt); + +if [[ "${content}" == *"No definitions found"* ]]; then + icon=""${HOME}"/.local/bin/img/caution-48.png" +else + icon=""${HOME}"/.local/bin/img/checkmark-32.png" +fi + +zenity --text-info \ + --window-icon="${icon}" \ + --filename="${HOME}"/.local/tmp/"${searchterm}".txt \ + --font="IBM Plex Mono Medium 11" \ + --width=750 \ + --height=600 2> /dev/null + +sleep 0.5 +rm -rf "${HOME}"/.local/tmp/"${searchterm}".txt diff --git a/scripts/spchk b/scripts/spchk new file mode 100755 index 0000000..2768593 --- /dev/null +++ b/scripts/spchk @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +function parseResults() { + oIFS=$IFS + IFS=":" + declare -a fields=($1) + + export QUERYTERM=$(echo "${fields[0]}"|awk '{print $1}'); + export LISTCOUNT=$(echo "${fields[0]}"|awk '{print $2}'); + export WORDLIST=$(echo "${fields[1]}"|sed 's/^\s*\|\s*$//g'); + + IFS=$oIFS + unset oIFS +} + +if [ $# -eq 0 ]; then + >&2 echo "Please provide a word for spell checking. Include quotes." + exit 1 +fi + +if [[ "$1" =~ ^[0-9]+$ ]]; then + cecho IWhite On_IRed "ERROR. Only Words Please. No Numbers!" + exit 1; +fi + +export RESULT=$(echo "$@"|aspell -a|sed "1 d"); # Deletes the header line +export FIXED="${RESULT/& }" # Removes ampersand causing parsing errors. + +if [[ "${FIXED}" == *"*"* ]]; then + cecho IBlack On_IGreen "CORRECT!" +else + parseResults "${FIXED}" + cecho IBlack On_IRed "INCORRECT!" + cecho Black On_Yellow "There are ${LISTCOUNT} suggested corrections for '${QUERYTERM}': ${WORDLIST}. " +fi diff --git a/scripts/speller b/scripts/speller new file mode 100755 index 0000000..759904a --- /dev/null +++ b/scripts/speller @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +function parseResults() { + oIFS=$IFS + IFS=":" + declare -a fields=($1) + + export QUERYTERM=$(echo "${fields[0]}"|awk '{print $1}'); + export LISTCOUNT=$(echo "${fields[0]}"|awk '{print $2}'); + export WORDLIST=$(echo "${fields[1]}"|sed 's/^\s*\|\s*$//g'); + + IFS=$oIFS + unset oIFS +} + +searchterm=$(zenity --entry --text="Enter search term:" --title="Speller" --width=300 --height=40 2> /dev/null); + +if [ -z "${searchterm}" ] | [ "${searchterm}" == " " ]; then + zenity --info --text="ERROR No search term provided!"\ + --icon-name=error \ + --window-icon="${HOME}/.local/bin/img/xmark.png" 2> /dev/null + exit 1; +fi + +if [[ "${searchterm}" =~ ^[0-9]+$ ]]; then + zenity --info --text="ERROR only words, please!"\ + --icon-name=error \ + --window-icon="${HOME}/.local/bin/img/xmark.png" 2> /dev/null + exit 1; +fi + +export RESULT=$(echo "$searchterm"|aspell -a|sed "1 d"); # Deletes the header line +export FIXED="${RESULT/& }" # Removes ampersand causing parsing errors. + +if [[ "${FIXED}" == *"*"* ]]; then + zenity --info --text="CORRECT! " \ + --icon-name=info \ + --window-icon="${HOME}/.local/bin/img/check-mark-11-16.png" 2> /dev/null + +else + parseResults "${FIXED}" + message="There are ${LISTCOUNT} suggested corrections for '${QUERYTERM}': ${WORDLIST}" + zenity --info --text="${message}"\ + --icon-name=warning \ + --window-icon="${HOME}/.local/bin/img/caution-48.png" 2> /dev/null + +fi