Monday, 12 December 2022

Mac: Set command alias

On all my computers I like to set up a dedicated drive where I keep my development work, often time's I find myself navigating through the command line to get to my dev drive, it's nothing crazy 

cd /Volumes/dev


however I prefer to have something a long the lines of 'gotodev' because I switch between my windows work pc and my home Mac it's just one of those little nice to haves.


On a Mac to set up a path alias, open up a new terminal and you should start your journey in your home directory, which is great, cause that is exactly where you want to be.


type in the command


ls .zshrc 


if nothing comes up then you need to create it, simply type in


touch .szhrc 


this will create a .zshrc file in your home directory

Next you are going to have to open it with the command


nano .zshrc


this will open your .zshrc file in a terminal text editor, and add the following line


alias gotodev='cd /Volumes/dev'


the result should look something like the following



Once you have added your alias exit the editor and make Sure you save your changes, and from now one when you type in 'gotodev' in your terminal you should be navigated to '/Volumes/dev'


to test out out your command hit commad+t to tab open a new command window and type in 'gotodev'