Creating Bash Profile Aliases for Quick Folder Access

Matthew Sedlacek
codeburst
Published in
2 min readDec 14, 2020

--

Photo by Safar Safarov on Unsplash

As a Software Engineer, I have many files and folders on my computer filled with my various coding projects. Therefore, having to navigate through the many different folders to get to the project I’m looking for in the terminal can take more than a few lines of code. Luckily, there is a better way to navigate to folders and projects. Enter Bash Profile Aliases.

Before discussing Bash Profile Aliases, let’s take a step back and review some terminology. Software engineers wanting to use the Command-Line Interface (CLI), need to open what’s called the terminal; short for terminal emulator. When the terminal is opened it, “…will immediately start a program called a shell program. The shell program is what actually prompts you for input and returns the output. The shell most computers default to using is known as bash”(Flatiron School).

Bash contains a Bash Profile where users are able to make customizations. To see where your bash profile and other hidden files/folders are on your computer you can type la -a in your terminal. To open your Bash profile and view it in your code editor type the following.

code ~/.zprofile

If you have not used your Bash Profile before it will be fairly empty. However, that will quickly change once you start adding your aliases. So, let’s walk through an example. Let’s say I want to add an alias for my projects folder. The first folder in the projects file path is Development, the next folder after development is code, and then the projects folder follows after that. So, to create the alias for projects I would add the following to my Bash Profile.

alias projects="cd ~/Development/code/Projects"

Now, in the terminal, I just need to type projects and I’m taken directly to the folder

Projects alias used in Terminal

Conclusion

Thank you for taking the time to learn about Bash Profile Aliases. I hope this blog will help save you time and keystrokes.

Resources

“Cli Essentials Bash Intro.” Learn, learn.co/tracks/module-1-web-development-immersive-3–0/fswd-prework-2–0/cli-essentials/bash-introduction.

--

--

Software Engineer — Full Stack, JavaScript, ReactJS, Ruby on Rails, OO Programming (https://www.matthewsedlacek.com/)