DEV Community

🇭🇹 DEDE
🇭🇹 DEDE

Posted on

Why is my alias not working?

alias cloud='cd ~/Users/diddy/Library/Mobile\ Documents/com~apple~CloudDocs'

I thought it was related to the escape character but it's not. I get the "No such file or directory" error.

Top comments (6)

Collapse
 
rhymes profile image
rhymes • Edited

The fact that it's on two lines seems to be the problem. You can use quoting for directories with spaces:

➜  ~ mkdir testalias
➜  ~ cd testalias
➜  testalias mkdir -p "Mobile Documents/com~apple~CloudDocs"
➜  testalias tree
.
└── Mobile\ Documents
    └── com~apple~CloudDocs

2 directories, 0 files
➜  testalias alias cloud='cd "Mobile Documents"/com~apple~CloudDocs'
➜  testalias cloud
➜  com~apple~CloudDocs pwd
/Users/rhymes/testalias/Mobile Documents/com~apple~CloudDocs

BTW make sure that the directory actually exists :)

Collapse
 
wilfrantz profile image
🇭🇹 DEDE

alias cloud='cd ~/Users/diddy/Library/"Mobile Documents"/com~apple~CloudDocs'

Still giving me the error message :-(

Collapse
 
rhymes profile image
rhymes • Edited

I got it, it's:

alias cloud='cd /Users/diddy/Library/"Mobile Documents"/com~apple~CloudDocs'

You have to remove the ~ at the beginning, that's an alias for /Users/diddy already

or you can do

alias cloud='cd ~/Library/"Mobile Documents"/com~apple~CloudDocs'
Thread Thread
 
wilfrantz profile image
🇭🇹 DEDE

Perfect, used alias cloud='cd ~/Library/"Mobile Documents"/com~apple~CloudDocs' and it finally worked.

Thank you 🤝

Collapse
 
jmervine profile image
Joshua Mervine

Try replacing ~ with $HOME.

Collapse
 
wilfrantz profile image
🇭🇹 DEDE

Sorry for the typos.