From 4ea9d9198f6c896be8993c5f5be8b1e2407c7c74 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Fri, 1 Mar 2024 11:46:09 +0000 Subject: [PATCH] cleanup def and cecho --- scripts/cecho | 5 +++-- scripts/def | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 scripts/def diff --git a/scripts/cecho b/scripts/cecho index 2a3964b..f91a22f 100755 --- a/scripts/cecho +++ b/scripts/cecho @@ -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" ] diff --git a/scripts/def b/scripts/def new file mode 100755 index 0000000..f3bdb0e --- /dev/null +++ b/scripts/def @@ -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 +