I want to set up a bash alias or function (let's call it "myfolder") to a common working directory (let's call it ~/some/deep/working/folder
) and I want to be able to call it like this:
cd myfolder/bob
to access the child folder "bob".
If I use alias myfolder='~/some/deep/working/folder'
, I can use cd myfolder
, but I can't use cd myfolder/bob
.
How do I get the alias expansion to happen first, and then have any other text be added onto the command before executing the command?
Two workarounds:
Add this to your .bashrc:
then you can use
from everywhere.
Use a variable: