Zsh: Automatically modify executed command

You could do it by redefining the accept-line widget:

add-grc() { [[ $BUFFER = grc* ]] || BUFFER="grc $BUFFER"; zle .$WIDGET "$@"; }
zle -N accept-line add-grc

However, it could cause problem for commands like "for i (..)", "var=x", "f() {"...


Other alternative. Same kind of potential problems:

TRAPDEBUG() { eval "grc $ZSH_DEBUG_CMD"; setopt errexit; }

I would use an "alias" for every command that needs "grc" instead of trying to figure out exceptions for the solutions posted here.


Consider using grc.zsh that's part of grc which can be found here. It has aliases for all supported commands.
See this Stackoverflow answer

Tags:

Terminal

Zsh

Osx