Skip to content

Instantly share code, notes, and snippets.

@gko
Created February 7, 2020 20:38
generate aliases from git
# generate aliases from gitconfig aliases
function generateAliasesFromGit() {
git config --get-regexp ^alias\\. | while read gitAlias; do
local aliasName=$(echo $gitAlias | sed -E 's/^alias\.([a-z_\-]*).*/\1/')
# alias only if there is no collision
if ! type "g$aliasName" >/dev/null 2>&1; then
alias g$aliasName="git $aliasName"
fi
done
}
generateAliasesFromGit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment