function grep if test "$pipestatus" = "0" # No pipe before the grep command grep -n --color=auto $argv else # There is a pipe before the grep command grep --color=auto $argv end end