1. You’ll need the direct path to your learn directory.
    for example: /Users/[you]/Development/code
    if you don’t know what it is you can always open atom and right click on the directory and click on “copy full path” then make sure to paste this somewhere where you can use later.
  2. Open your terminal and create a bash_aliases file
    vi ~/.bash_aliases
  3. This will open up the file in the vi editor which is not how we want to edit this file. Type in :wq (this will save the file and bring you back to the terminal.
  4. Next, let’s open up the same file with our default text editor
    open -e ~/.bash_aliases
  5. Type in any alias that you want with the alias syntax
    alias [name_of_alias]=[command]
    for example alias home=“cd ~”
  6. To chain alias commands together we need to create a function. To cd into a learn directory AND open atom, we will do this:

    yourfunctionname() {
    cd 'enter your full path to learn directory including the single quotes'
    atom .
    }
    for example:
    codetime(){
    cd '/Users/yosayon/Development/code'
    atom .
    }
  7. command+s to save and exit the text editor.
  8. Now let’s tell your bash profile to load this file every time you open terminal. This tells your computer that you can use these aliases any time in your terminal as long as you’re signed into bash.
  9. In the terminal:
    open -e ~/.bash_profile
  10. Copy and paste the below code into your bash profile in the very top

    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    command + s to save, exit the text editor.
  11. Restart your terminal and exit Atom completely so we can test this out.
  12. Type in the name of your function inside your terminal and atom should open up with your learn directory!
    =)

Leave a Reply

Your email address will not be published. Required fields are marked *