loading...

Why is my alias not working?

wilfrantz profile image πŸ‡­πŸ‡Ή DEDE ・1 min read

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.

Discussion

markdown guide
 

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 :)

 

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

Still giving me the error message :-(

 

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'

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

Thank you 🀝