I want to create an alias in bash, such that
git diff somefile
git diff --color somefile
But I don’t want to define my own custom alias like
alias gitd = "git diff --color"
because if I get used to these custom alias, then I loose the ability to work on machines which don’t have these mappings.
Edit: It seems bash doesn’t allow multi-word alias. Is there any other alternative solution to this apart from creating the alias?
Better answer (for this specific case).
git-config man page:
color.diff When set to always, always use colors in patch. When false (or never), never. When set to true or auto, use colors only when the output is to the terminal. Defaults to false.
No function or alias needed. But the function wrapper approach is general for any command; stick that card up your sleeve.
Answered By – Kaz