3

When I am typing in a typical alias with my .bash_profile, my change directory is not working.

I currently have the following:

alias cdicloud="/Users/<username>/Library/Mobile Documents/com~apple~CloudDocs/Folder1/subFolder

Does anyone know how to properly change directories via an alias. All my other aliases work, but this one doesn't want to work.

1 Answer 1

4

You need to escape/protect any spaces etc in the path:

alias cdicloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs"

Executing this in Terminal looks like the following:

pse@Mithos:~$ alias cdicloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs"
pse@Mithos:~$ cdicloud 
pse@Mithos:~/Library/Mobile Documents/com~apple~CloudDocs$ cd -
/Users/pse
pse@Mithos:~$ 
4
  • When I enter that, I get a No such file or directory error, as it is removing the / after Documents.
    – stuartjash
    Oct 8, 2018 at 18:08
  • @CrashBurner Strange, I copied this directly from my own .bash_profile. What does type cdicloud say?
    – nohillside
    Oct 8, 2018 at 18:13
  • It says: cd ~/Library/Mobile\ Documents\com~apple~CloudDocs/F1/F18. Yet in my alias, it reads exactly as follows: alias cdicloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/F1/F18"
    – stuartjash
    Oct 8, 2018 at 18:17
  • Your addition to the initial response worked. Thank you!
    – stuartjash
    Oct 8, 2018 at 18:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .