Created
February 7, 2020 20:38
-
-
Save gko/c68dc17db3db7aeeb6a510c7c4b8319d to your computer and use it in GitHub Desktop.
generate aliases from git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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