Search code examples
grepzshaliases

Create an alias for "pipe grep"


I would like to create an alias for | grep

eg, for example be able to write:

ps -axf G chrome instead of ps -axf | grep chrome

I've written the following in my aliases file of oh-my-zsh:

alias -g G= '| grep --color'

However, this doesn's seem to work.

Any idea why ?

EDIT

I get the following error when I write ps -axf G chrome

error: must set personality to get -x option

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).

It seems that the G is interpreted as being part of the ps command


Solution

  • Your alias statement can't have space between assignment:

    alias -g G='| grep --color'