paint-brush
Bash Aliases: Take Them With Youby@atulthosar
252 reads

Bash Aliases: Take Them With You

by Atul ThosarMay 9th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Software associates create aliases and write them in the `~/.bashrc` file. aliases are available whenever they logged in to their machine. It's very difficult to copy/paste the aliases every time s/he logs in to the another machine. Create your aliases, categorize and put them in different files.
featured image - Bash Aliases: Take Them With You
Atul Thosar HackerNoon profile picture

*nix Aliases

We all know how aliases on the *nix system help to create short commands for the long ones. E.g. kga can stand for kubectl get all or gl for git log --name-status --decorate. Software associates create such aliases and write them in the ~/.bashrc file. So aliases are available whenever they logged in to their machine.

The Challenge

However, associates also need to log in to other *nix machines for various purposes. Say a developer needs to log in to the SV system for live troubleshooting of an issue. Or a DevOps Engineer requires to log in to various cloud VMs. One has become very used to his/her alias s/he has created. It's very difficult to copy/paste the aliases every time s/he logs in to the another machine.

The Solution

Here is one way to address this challenge. Create your aliases, categorize and put them in different files. Say General Aliases, Git Aliases, Docker Aliases etc. Then create a setaliases.sh file. Download it on the machine you have logged in.


wget https://raw.githubusercontent.com/simplyatul/bin/master/setaliases.sh


and then source it


source setaliases.sh


That's it. All your aliases are set.


If you are frequently logging in to a particular machine, then just copy the above source command in the ~/.bashrc file.


Also published here.