You can visualize your current tab stops with setterm --tabs.
for "git add -p", you might want your tab stops to look like this:
10 20 30 40 50
12345678901234567890123456789012345678901234567890123456789
T T T T T T T T T T T T T T
not this:
10 20 30 40 50
12345678901234567890123456789012345678901234567890123456789
T T T T T T T T T T T T T T
To get the first one, you can use tabs -c3 (read here).
To get the second one, you can use tabs -4.
However, you will break your cat output if you use tabs -c3 (cat needs tabs -4).
So you need tabs -c3 only when running git add -p.
Here is how I do it:
git() {
if [[ "$1" == "add" ]] &&
[[ "$2" == "-p" ]] || [[ "$2" == "--patch" ]]
then
tabs -c3
if [[ "$#" -eq 2 ]]
then
command git add -p
else
command git add -p "$3"
fi
tabs -4
else
command git "$@"
fi
}
put it in your .bashrc and/or .zshrc