Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Moving completion functions



I wrote:
> The other thing which might be worth doing is looking through any other
> functions any of us have. From these we may find some suitable for the

> I've attached two of mine: hgrep is like grep but highlights

Of course, it would help if I actually remembered to attach them.
They should be on this e-mail.

Oliver
# hgrep - highlight grep

if (( ! $# )); then
  echo "Usage: $0:t [-e pattern...] [file...]" >&2
  return 1
fi

local -a regex
local htext=`echotc so` ntext=`echotc se`

while [[ "$1" = -e ]]; do
  regex=( $regex "$2" )
  shift 2
done

if (( ! $#regex )); then
  regex=( "$1" )
  shift
fi

regex=( "-e
s/${^regex[@]}/$htext&$ntext/g" )
sed ${(Ff)regex[@]} "$@"
local arg s

(( $# == 1 )) || s=s
echo received $# argument$s

for arg; do
  echo -E - ">>$arg<<"
done


Messages sorted by: Reverse Date, Date, Thread, Author