DEV Community

Cover image for Generating shorter aliases from .gitconfig file
Konstantin
Konstantin

Posted on • Updated on

Generating shorter aliases from .gitconfig file

In previous articles I showed how to configure aliases in your ~/.gitconfig file.

As you might have noticed you need to type git alias which might be inconvenient. Even if you make an alias g=git you have to remember to type space between g and alias.

To make things easier we can automatically generate shell aliases from the .gitconfig file:

here we grep all the git config values from alias section and get the alias name with sed. Then we check that alias g + alias name doesn't already exist and set it.

Now, if you had for instance alias a = add you can type both g a and ga.

That's it.

Oldest comments (0)