cleanup def and cecho

This commit is contained in:
Greg Gauthier 2024-03-01 11:46:09 +00:00
parent c2099140aa
commit 4ea9d9198f
2 changed files with 19 additions and 2 deletions

View File

@ -74,10 +74,11 @@ function cecho(){
On_ICyan='\033[0;106m' # Cyan
On_IWhite='\033[0;107m' # White
NC="\033[0m" # No Color
NC='\033[0m' # No Color
# printf "${(P)1}${2} ${NC}\n" # <-- zsh
printf "${!1}${!2}${3} ${NC}\n" # <-- bash
msg=${3%%*( )}
printf "${!1}${!2}${msg}" && printf "${NC}" && printf "\n" # <-- bash
}
if [ -z "$1" ]

16
scripts/def Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
mkdir -p ${HOME}/.local/tmp
dict -h localhost -d gcide "$@" > ${HOME}/.local/tmp/"${1}".txt 2>&1
content=$(cat ${HOME}/.local/tmp/"${1}".txt);
rm ${HOME}/.local/tmp/${1}.txt
if [[ "${content}" == *"No definitions found"* ]]; then
#./cecho IYellow On_Blue "$(cat ${HOME}/.local/tmp/${1}.txt)"
./cecho IYellow On_Black "${content%%*( )}"
else
#./cecho Black On_White "$(cat ${HOME}/.local/tmp/${1}.txt)"
./cecho IWhite On_Black "${content%%*()}"
fi