The zsh Shell has the possibility to define global aliases. That is, the alias can be used everywhere on the command line and not only at the beginning of the input.

Such a global alias is defined like so:

alias -g H='| head'
alias -g T='| tail'
alias -g G='| grep'
alias -g L="| less"
alias -g LE="| wc -l"
alias -g S="| sort"

Given the above example, everywhere on the command line where G occurs, it is replaced by | grep. The shell is smart enough to do this only where expected (not inside quotes for example).

I guess you already see where this is heading:

$ cat foodlist.txt
pizza
milk
eggs
salad
cookies
chocolate
$ cat foodlist.txt G i
pizza
milk
cookies
$ cat foodlist.txt H -n 2 G a
pizza

This saves you a couple of keystrokes every time you use head, tail, grep, less etc. in a pipe.

As a little side note, I feel it is often faster to chain multiple grep invocations if possible:

# assuming you search for lines containing "this" and "that"
$ output-producing-cmd G "this" G "that"

By the way, you’ll find most of these aliases defined in the common-aliases plugin of oh-my-zsh.