diff options
author | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-13 15:11:32 +0000 |
---|---|---|
committer | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-13 15:11:32 +0000 |
commit | 8c06d384ec85601efbf05036ee853dc6a6a9c3a5 (patch) | |
tree | aabdcfc59b8ce2386ca043fe2d8ebae584c3a1cc /grepjournal | |
parent | d4ea47ad7e979e4280eecbe947b729c6b9ac65bc (diff) |
replaced tput subshell commands with escape codes
Diffstat (limited to 'grepjournal')
-rwxr-xr-x | grepjournal | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/grepjournal b/grepjournal index df02d40..3f4229e 100755 --- a/grepjournal +++ b/grepjournal @@ -2,12 +2,12 @@ # Search ~/Notes/journal for a term and return as a markdown list sorted by date. -colourWhite="$(tput setaf 7)" -colourGreen="$(tput setaf 2)" -colourYellow="$(tput setaf 3)" -colorCyan="$(tput setaf 6)" -txBold="$(tput bold)" -txReset="$(tput sgr0)" +colourWhite="\033[38;2;255;255;255m" +colourGreen="\033[38;2;0;255;0m" +colourOrange="\033[38;2;249;130;44m" +colourCyan="\033[38;2;0;255;255m" +txBold="\033[1m" +txReset="\033[0m" # Automatic cleanup trap 'rm -f "$grepped_results"' EXIT @@ -25,7 +25,7 @@ echo [[ -n "$2" ]] && [[ -n "$1" ]] && searchterm="$1" && flag="$2" # some confirmatory echoing -echo "${colourWhite}Search term: ${txBold}$searchterm${txReset}" +echo -e "${colourWhite}Search term: ${txBold}$searchterm${txReset}" [[ -v flag ]] && echo "Flag: $flag" if [[ $flag != "-i" ]]; then @@ -46,7 +46,8 @@ echo "" # subsitute to get the right format using sed # form: 2022-01-10 12:49: :TODO Do the MyHR content: ht -urlregex="(https?:\/\/([[:alnum:]]+\.)+([[:alnum:]]+)+.*\s?)" +# urlregex="(https?:\/\/([[:alnum:]]+\.)+([[:alnum:]]+)+.*\s?)" +urlregex="https?" re='^/home/lemon/Notes/journal/([0-9]{4})-([0-9]{2})-([0-9]{2})\.md:-\s([0-9]{2}:[0-9]{2}):\s(.*)' while IFS= read -r line; do if [[ $line =~ $re ]]; then @@ -58,11 +59,11 @@ while IFS= read -r line; do fi out_line="${colourGreen}"$year"-"$month"-"$day":${txReset} ${note}" if [[ $out_line =~ $urlregex ]]; then - echo ${BASH_REMATCH[1]} + out_line=${out_line/${BASH_REMATCH[0]}/${colourCyan}${BASH_REMATCH[0]}${txReset}} fi if [[ $out_line =~ $searchterm ]]; then - o=${out_line/$searchterm/"${colourYellow}${txBold}$searchterm${txReset}"} - echo "$o" >> "$output_file" + o=${out_line/$searchterm/"${colourOrange}${txBold}$searchterm${txReset}"} + echo -e "$o" >> "$output_file" fi done < "$grepped_results" |