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:
CDPATH="$CDPATH:$HOME/some/deep/working"
then you can use
cd folder/bob
from everywhere.
Use a variable:
myfolder="$HOME/some/deep/working/folder"
cd "$myfolder/bob"
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다