Better Aliases
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:
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:
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:
By the way, you’ll find most of these aliases defined in the common-aliases
plugin of oh-my-zsh.