<commit_before>#!/bin/bash

declare -a exclude_files=(cscope.* GPATH GRTAGS GSYMS GTAGS)
declare -a exclude_dirs=(.git)

for f in ${exclude_files[*]};do GREP_OPTIONS+=" --exclude=$f";done
unset exclude_files;

for d in ${exclude_dirs[*]};do GREP_OPTIONS+=" --exclude-dir=$d";done
unset exclude_dirs;

export GREP_OPTIONS
export GREP_COLORS='fn=01;36:ln=01;32'<commit_msg>Add function "highlight" to highlight given words using grep<commit_after>#!/bin/bash

declare -a exclude_files=(cscope.* GPATH GRTAGS GSYMS GTAGS)
declare -a exclude_dirs=(.git)

for f in ${exclude_files[*]};do GREP_OPTIONS+=" --exclude=$f";done
unset exclude_files;

for d in ${exclude_dirs[*]};do GREP_OPTIONS+=" --exclude-dir=$d";done
unset exclude_dirs;

export GREP_OPTIONS
export GREP_COLORS='fn=01;36:ln=01;32'

function highlight()
{
  local pattern="^"
  while [[ $# -gt 1 ]];do
    pattern+="|$1"
    shift
  done

  if [[ -r $1 ]];then
    local filename="$1"
  else
    pattern+="|$1"
  fi

  grep -E "$pattern" $filename
}
{'fraction_non_alphanumeric': 0.16683217477656406, 'fraction_numerical': 0.020854021847070508, 'mean_word_length': 5.146341463414634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4778192', 'n_tokens_mistral': 435, 'n_tokens_neox': 391, 'n_words': 93}