alias 'gsi=<<eof grep --color'
Would work as alias is just like preprocessor text replacement, where the replacement is interpreted as shell code again.
Yours was not working as you had that "$1"
. With gsi file.txt
replaced with cat <<eof | grep --color "$1" file.txt
, then the shell carries on interpreting that command line and $1
at that point is the shell's first positional parameter which is probably empty unless you did a set something
beforehand. So you'd want to remove that "$1"
here. You can remove the UUOC as well.
gsi() { cat <<eof | grep --color "$1" ; }
is wrong from a syntax point of view as the eof
line is missing after that cat <<eof
.