Speed up development by adding bash aliases
Paweł Dąbrowski
Posted on January 1, 2020
Currently, I'm using two git accounts with separated keys, one for side projects and one for the company I'm working for. I have to switch to the second account each time I am using a new shell window and want to push changes using a different account:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/company
git push origin something
it is quite annoying. However, it can be easily replaced with a simple bash alias with a meaningful name that you would always remember.
Creating a bash alias
Mainly, there are two user-level files which system run when a bash shell starts - ~/.bash_profile
and ~/.bashrc
. You have to edit one of them to add our alias. The alias format is the following:
alias alias_name='command1;command2'
in my case I have to run two commands so the alias looks like this:
alias company_git='eval "$(ssh-agent -s)";ssh-add ~/.ssh/company'
Now I can simply type company_git
in terminal each time I open a new shell window and I want to be ready to push some code to the company repositories. It's so simple but makes the development less frustrating.
Thank you for reading! Follow me on Twitter to be up to date with the latest tips, articles, and videos about programming.
Posted on January 1, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.