From b6ddbcb73cc111154b6b23cc3905ec5f35b43f4d Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Sat, 13 Mar 2021 19:13:33 +0300 Subject: [PATCH] Pretify `dict` script --- home/.local/bin/dict | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/home/.local/bin/dict b/home/.local/bin/dict index 121a7dd..e4b511d 100755 --- a/home/.local/bin/dict +++ b/home/.local/bin/dict @@ -1,7 +1,13 @@ #!/bin/sh +cyan=$(tput setaf 6) +red=$(tput setaf 1) +bold=$(tput bold) +underline=$(tput smul) +esc=$(tput sgr0) + if [ -z "$1" ]; then aspell dump master | sort | fzf --no-multi | xargs dict else - curl "dict://dict.org/d:$1" + curl -s "dict://dict.org/d:$1" | sed -n -e '/^151.*/,/^\./p' | sed -e 's/^151.*//g' -e '/^\./D' -e '/^\s*1\./i\\' -e "s/{\([^{]*\)}/${esc}${bold}${underline}\1${esc}/g" -e "s/^\($1\)\(\W\)/${esc}${bold}${red}\1${esc}\2/gI" -e "s/^\(\s*\)\([0-9]\.\)/\1${esc}${bold}${cyan}\2${esc}/g" -e 's/--/—/g' -e 's/—\(\w\)/— \1/g' fi