<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Anmolpreet Kaur</title>
    <description>The latest articles on Forem by Anmolpreet Kaur (@anmolk18).</description>
    <link>https://forem.com/anmolk18</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F409853%2F78d22f50-c667-478a-b39d-12a30fae0059.png</url>
      <title>Forem: Anmolpreet Kaur</title>
      <link>https://forem.com/anmolk18</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anmolk18"/>
    <language>en</language>
    <item>
      <title>How to Save Valuable Time with Bash Aliases</title>
      <dc:creator>Anmolpreet Kaur</dc:creator>
      <pubDate>Tue, 16 Jun 2020 00:42:58 +0000</pubDate>
      <link>https://forem.com/anmolk18/how-to-save-valuable-time-with-bash-aliases-jee</link>
      <guid>https://forem.com/anmolk18/how-to-save-valuable-time-with-bash-aliases-jee</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aVAomNLK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pkx0vd8fc3jnracj7usn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aVAomNLK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pkx0vd8fc3jnracj7usn.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a new programmer, discovering a mystical terminal in my computer was astonishing. But as I started to code, I found it very annoying when I had to type the same commands over and over again into my terminal. I was pleasantly surprised when I learned about bash aliases that I could write to save time!&lt;/p&gt;

&lt;p&gt;You can write bash aliases to shorten simple commands as well as bash functions to put multiple commands together. On Unix-based operating systems, custom bash commands are a life-changer! Just follow these simple steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Open your terminal.&lt;/strong&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Enter these commands to view hidden files:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cd ~&lt;/code&gt;&lt;br&gt;
&lt;code&gt;ls -a&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Open your bash profile.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You should see a list of files after typing the commands above. If your computer uses a login shell, open .bash_profile in any text editor. If your computer uses a non-login shell, open .bashrc in any text editor.&lt;br&gt;
To check if your computer uses a login shell, type the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;echo $0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If it returns -bash (with “-” as the first character), you are in a login shell. If it returns bash (where “-” is NOT the first character), you are in a non-login shell.&lt;br&gt;
If you are unsure about how to open a file from your terminal, look &lt;a href="https://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windows"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Once the bash profile is open, you are ready to write your custom bash commands at the bottom of the file!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To write an alias, use the following format:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;alias c='clear'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This alias will allow you to just type c into your terminal every time you want to clear it.&lt;/p&gt;

&lt;p&gt;More examples of useful aliases:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;alias .='cd ..'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;alias gc='git clone'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;alias labs='cd ~/Flatiron/Mod2/Labs/'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;alias bi='bundle install'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;alias gu='anmolk18@github.com'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can write a function to put multiple commands together like this:&lt;br&gt;
&lt;code&gt;function gacp() {&lt;br&gt;
git add . &amp;amp;&amp;amp;  git commit -m "$1" &amp;amp;&amp;amp; git push origin $2&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
If you need to pass arguments into the function, the first parameter will be stored in $1, the second in $2, and so on. When using GitHub, using the function above will be very helpful. To add, commit with a message, and push to the master branch, all you have to type into your terminal is:&lt;br&gt;
&lt;code&gt;gacp "CLI done" master&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Once you have written your aliases, save the file and open your terminal to use them!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;(Note: If your terminal was already open, you may need to close it and open it again for the newly saved aliases to work.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V_M0S5sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zt7hu4mgznnm15ghhyfq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V_M0S5sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zt7hu4mgznnm15ghhyfq.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;References:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell"&gt;Difference between Login Shell and Non-Login Shell&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/swlh/creating-new-bash-commands-and-aliases-c9272fd589c4"&gt;Creating new bash commands and aliases&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/an-intro-to-git-aliases-a-faster-way-of-working-with-git-b1eda81c7747/"&gt;An Intro to Git Aliases: a faster way of working with Git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>linux</category>
      <category>bash</category>
      <category>alias</category>
    </item>
  </channel>
</rss>
