I would like to prepend
clear; to all commands in terminal mode. This reduces the amount of 'clutter' in my terminal screen and makes things slightly clearer for me.
In Bash and Zsh, a
DEBUG trap can be used to chain a given set of commands or function
to each issued command. Thus,
trap 'clear; "$@"' DEBUG
solves your problem.
Presumably you do not want to do it manually every single time, nor to affect every
interactive shells, only those in Vim's terminal buffer.
In that case, the solution is to add this to your
[ -n "$VIM_TERMINAL" ] && trap 'clear; "$@"' DEBUG
The test verifies if the
VIM_TERMINAL environment variable is set;
if yes, it sets the trap.