How to Create and Delete BASH Profile Aliases
Suppose you have a project folder deeply nested inside a tree of directories on your machine and you have to type in a long command line script like this to get to it:
cd Documents/Development/Freelance/my-freelance-project/my-freelance-project-front-endWe can easily make that much easier to enter using aliases. Thankfully, they are easy to set up (and remove).
Create an alias
To save the above as an aliases, simply open your command line and type:
alias freelance=”cd Documents/Development/Freelance/my-freelance-project/my-freelance-project-front-end”Now all you have to do is type freelance in your terminal and you’re already saving yourself the trouble!
Note: If you created an alias for a cd command, make sure you include the full path starting with ~/ so that the alias works no matter what directory you’re currently located in.
Note 2: Depending on your terminal emulator, you may need to restart or type source ~/.bash_profile to start using the alias.
Delete an alias
This is even easier. To delete the alias above, all I need to do is:
unalias freelanceFun fact: You can run this command from any directory and it’ll work.
View all of defined aliases
To see a list of all the alias that have been created in your bash profile, all you need to do is type in:
aliasAnd BAM, you have a readout of all the aliases that are currently defined.
