--color=always is there to tell git to output color codes even if the output is a pipe (not a tty). And -r is there to tell less to interpret those color codes and other escape sequences. Use -R for ANSI color codes only.
The curses program tabs will allow you to change what the terminal believes to be the width of a ^I. This would make a simple script
tabs -4
cat "$@"
tabs -8
However, the processing of tab characters on terminals is notoriously wonky and I'm of the impression that you should never mess with them. I suggest using expand as in:
expand -4 "$@"
which is actually closer to what you intend.
added in reply to comment:
Far too many scripts count on cat meaning /bin/cat which explicitly does not change tabs. I'm not sure if you mean to replace or supersede /bin/cat, but you shouldn't. Better would be:
Best Answer
Yes, it is possible with
less -x
orless --tabs
, e.g.less -x4
will set the tabwidth to 4.You can configure defaults with the
LESS
environment variable, e.g.LESS="-x4"
.