Access iCloud Drive via terminal

OS X 10.10 was just released, and one of the features I personally awaited the most was iCloud Drive. Unfortunately, I had to learn that it was not as accessible as Dropbox.

file ~/Dropbox /Users/Ingwie/Dropbox/: directory 
. but, iCloud Drive?
ls -1 Library/Mobile\ Documents/ ./ ../ .DS_Store 57T9237FN3~net~whatsapp~WhatsApp/ 5U8NS4GX82~com~dayoneapp~dayone/ (. ) 

Does anybody know, how to correctly access iCloud Drive via terminal? Or is this simply not possible and only presented nicely by the Finder App?

asked Oct 17, 2014 at 15:38 Ingwie Phoenix Ingwie Phoenix 1,367 2 2 gold badges 13 13 silver badges 18 18 bronze badges

6 Answers 6

Step One, Setup a Link to the iCloud Drive Folder actual path:

First, create a link in your home directory to your iCloud drive:

cd ~ ln -s ~/Library/Mobile\ Documents iCloud 

The lines above do the following:

// brings you to home directory // creates link to said path as the name, 'iCloud' 

Typing cd ~/iCloud in terminal will now deliver you to this directory.

Step Two, Setup your Aliases in your Bash Profile:

Once, a link has been established, we need to setup an alias. Aliases are removed once we restart terminal, so we have to add an extra step where we edit a file called .bash_profile (or create one if we don't have one already).

Once done, we can simply type any binding and be delivered to our desired directory. In this example, we'll use i to take us right to our iCloud Documents folder.

We can create an alias to the iCloud Drive folder and save it in our bash profile as follows:

cd ~ ls -a 

Look for a file called .bash_profile .

If you don't have .bash_profile , type:

Enter your admin password and press enter.

Once you have found .bash_profile , or finished creating it, we must now open it and define our alias inside as follows. Type:

You will again be prompted to enter you admin password. Enter it and press enter.

This will load up the nano editor. Press esc to be able to edit, and using the keyboard, arrow key down to the bottom. Type:

alias i="cd ~/iCloud/com~apple~CloudDocs/Documents" 

Press Ctrl + O to save, and then enter , then press Ctrl + X to exit.

Your alias is now saved. If we had not edited our .bash_profile , and just typed the alias in terminal, it would be erased when we restarted terminal. Adding this command into our bash profile will prevent this.

Type your Alias in Terminal:

Now that you've saved your alias to your .bash_profile , we must finally execute our alias at least once (I tried not doing this and it didn't work), by re-typing our alias in the general terminal:

alias i="cd ~/iCloud/com~apple~CloudDocs/Documents" 

This will create the alias, and will now work. If you restart terminal, and run your alias command again, it should also still work.

Results:

After this setup, we can simply type: i into the terminal, which will load our iCloud Drive\Documents directory.

Note: You can create any number of aliases to any folder, using any key binding you'd like, using the formula above. I just chose the Documents folder as this was the OP's question.

The above strategy was outlined in a tech blog article here: https://danielmiessler.com/blog/access-icloud-drive-terminal

How I Set Mine Up:

I setup an alias called idev where by typing that in terminal, delivers me to a Development folder I created on my iCloud drive at:

~/iCloud/com~apple~CloudDocs/Development 

Note, the line above is still using the link setup initially in Step One.

My personal Alias I setup is as follows:

alias idev="cd ~/iCloud/com~apple~CloudDocs/Development" 

Using a link and then an alias can allow us to access the iCloud docs folder easily. The most confusing part is editing the .bash_profile file, but overall just follow the steps and now any time you open terminal your aliases should work!