4

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

edi9999
  • 19,701
  • 13
  • 88
  • 127

2 Answers2

2

I have

alias -g G=' | grep -i '

so the syntax seems OK

so I can do :-

cat file.txt G fred

are you actually running zsh (echo $SHELL)

zzapper
  • 4,743
  • 5
  • 48
  • 45
1

Your alias statement can't have space between assignment:

alias -g G='| grep --color'
konsolebox
  • 72,135
  • 12
  • 99
  • 105