Just Start Typing Text and Press Enter

Menu
Close
Feb 05, 2017

Add an Alias to a Bash Profile to Streamline Workflow

0 Comment | By
alias bash profile

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.

  1. 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.
  2. ls -alh – By entering this will be able to see the names of all files including hidden files.
  3. 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]
  4. 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.
  5. In our .bash_profile we will enter the following:
  6. 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
  7. Now save your .bash_profile
  8. You’re done. Now simply launch another terminal window to activate it.

Adding an Alias to MacOSX:

To get started on MacOSX 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:

  1. 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.
  2. ls -alh – By entering this will be able to see the names of all files including hidden files.
  3. 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]
  4. 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.
  5. In our .bash_profile we will enter the following:
  6. 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
  7. Now save your .bash_profile
  8. Now you will need to reload your .bash_profile by running the following:
  9. Enter in the Terminal Window source ~/.bash_profile
  10. 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.

Share Post
DON'T MISS ANY UPDATES