diff options
author | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-13 15:47:00 +0000 |
---|---|---|
committer | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-13 15:47:00 +0000 |
commit | 1937dbfec2d18a40875397ec70bb9bfef2f37208 (patch) | |
tree | 35fa489cabf4cc2ff59df8be82536e45eaca1640 | |
parent | 9c2103e72f21caedae53dd0cb572f666502025b0 (diff) |
some light refactoring
-rwxr-xr-x | grepjournal | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/grepjournal b/grepjournal index 2f31fa3..9c929fe 100755 --- a/grepjournal +++ b/grepjournal @@ -18,6 +18,7 @@ grepped_results=$(mktemp) || exit 1 trap 'rm -f "$output_file"' EXIT output_file=$(mktemp) || exit 1 +# nice line across the top termsize=$(stty size| awk '{print $2}') printf "${colourWhite}=%.0s" $(seq $termsize) echo @@ -43,12 +44,7 @@ echo "Command: 'grep -R $flag $searchterm /home/"$USER"/Notes/journal/'" printf "=%.0s" $(seq $termsize) echo "" -# URL regex - - -# 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?)" +# because I can't get the regex right, I am searching for http or https to indicate a link in a line 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 @@ -64,8 +60,8 @@ while IFS= read -r line; do out_line=${out_line/${BASH_REMATCH[0]}/${colourCyan}${BASH_REMATCH[0]}${txReset}} fi if [[ $out_line =~ $searchterm ]]; then - o=${out_line/$searchterm/"${colourOrange}${txBold}$searchterm${txReset}"} - echo -e "$o" >> "$output_file" + out_line=${out_line/$searchterm/"${colourOrange}${txBold}$searchterm${txReset}"} + echo -e "$out_line" >> "$output_file" fi done < "$grepped_results" |