Sample Header Ad - 728x90

Create auto alias of every folder in a specific folder in bash_profile or bash_alias

2 votes
1 answer
369 views
Using *macOS Sonoma 14.2.1* We created an alias in .bash_profile or .zsh_profile and added the alias like this:
alias dev='cd ~/Developer'
Now there are many folders inside this and for each project I have to create alias for that to access early. Now in *Developer* folder there are 3 project folders:
.Developer
├── apple
├── canvas
└── demo
Currently, I created separate alias for each folder to access them as below:
alias apple='cd ~/Developer/apple'
alias canvas='cd ~/Developer/canvas'
alias demo='cd ~/Developer/demo'
This works fine but I am looking for any optimal solution or bash script which automatically generate an alias for each folder of a specific folder and add into .bash_profile. Or when creating new folder in this directory, it automatically adds new alias for the new folder.
Asked by xkeshav (247 rep)
Feb 4, 2024, 08:11 AM
Last activity: Feb 4, 2024, 06:42 PM