Skip to content

Instantly share code, notes, and snippets.

@gko
Created February 7, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gko/c68dc17db3db7aeeb6a510c7c4b8319d to your computer and use it in GitHub Desktop.
Save gko/c68dc17db3db7aeeb6a510c7c4b8319d to your computer and use it in GitHub Desktop.
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