Just Start Typing Text and Press Enter

Add an Alias to a Bash Profile to Streamline Workflow

Add an Alias to a Bash Profile to Streamline Workflow

Alias, some of us know what the are but many of us do not know how to create or manage them. Recently I have began trying to streamline my Linux and MacOSX commands by adding some Alias to my bash profile. If you are not familiar with this it could help you really you as it is easy to do and as we all know the best command is the shortest. So with that in mind I will be breaking this down in to how to add an Alias to a Bash Profile for Linux Interfaces as well as MacOSX.

Adding a Alias to Linux:

To get started we will first need to Launch Terminal one we have a terminal window launched navigate through the following steps.

cd /home/[your_login_name]/ – Here you will need to enter your login name, in my case mine would be david. If you do not know what your username is simply type the name users to see what yours is.

ls -alh – By entering this will be able to see the names of all files including hidden files.

vi .bash_profile – This will open the vi text editor, if you prefer to use another editor such as nano or emacs simply type the respective command as such [/code]nano .bash_profile[/code]

Once the editor has opened and you have familiarized yourself with typing with in it and committing a save with in it. Simply enter the following command as an example to streamlining a long command. We will use step #2 above as an example.

In our .bash_profile we will enter the following:

alias l='ls -la' – What this means is if we type the letter l and hit enter on the command line the command ls -alh

To get started on Mac OSX as we did before in our Linux walkthrough above we will need to Launch Terminal. To do this simply go to Applications > Terminal and enter the following:

cd /Users/[your_login_name]/ and press enter – Here you will need to enter your login name, in my case mine would be david. If you do not know what your username is simply type the users and press enter to see what yours is.

ls -alh – By entering this will be able to see the names of all files including hidden files.

vi .bash_profile – This will open the vi text editor, if you prefer to use another editor such as nano or emacs simply type the respective command as such nano .bash_profile

Once the editor has opened and you have familiarized yourself with typing with in it and committing a save with in it. Simply enter the following command as an example to streamlining a long command. We will use step #2 above as an example.

In our.bash_profile we will enter the following:

alias l='ls -la' – What this means is if we type the letter l and hit enter on the command line the command ls -alh

Now save your .bash_profile

Now you will need to reload your .bash_profile by running the following:

Enter in the Terminal Window source ~/.bash_profile

You’re done! Now give your new alias a try by entering l into your terminal window! You just saved yourself from typing a bunch of unneeded characters.

That’s it! I know we can write a one liner here to do everything that we need, however I feel it is most important to teach people how the CLI works and how to commit changes to an editor via the command line. In my next post I will be sharing my personal aliases and how the help my work follow.