How do I access my iCloud Drive folder from Terminal? - terminal

I'm running OS X Yosemite. I would like to save my code folder in iCloud Drive so that it's automatically backed up. I need to access files from the Terminal often, so how can I access iCloud Drive from the Terminal?

cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/
I would just add a symbolic link either to this folder or to a Source subfolder in your home directory to make working with this easier.
For example:
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ~/iCloud
and/or
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Source ~/Source

It´s in the Library Folder of the user. The folder-name is "MobileDocuments".

It's in ~/Library/Mobile\ Documents/com\~apple\~QuickTimePlayerX/Documents/....
How to find it? You can drag a file in the finder and drop the file to the terminal, then the file path would be displayed in the terminal.
This is an awful way to get the path, I'm very curious about how to reveal it more naturally and easily and gracefully.

Related

Is it possible to change the Xcode's iOS DeviceSupport default folder location?

I want it to point to an external drive and save some memory on main drive.. please assist.. so far it seems that it's impossible to do so. Only Archive and DerivedData can be configured via Locations preference..
There is no such option. But you can symlink the destination with ln -s command. Something like this:
% ln -s /ExternalDrive/DeviceSupport/ ~/Library/Developer/Xcode/iOS\ DeviceSupport/
So,
Close the Xcode
Move the DeviceSupport directory to the destination where you want to store it
Symlink the new destination
Launch Xcode and check that everything works as expected
PS Check the How to Create Symbolic Links at Command Line of Mac OS X guide if you need more information about linking.

WSL: Using A WSL symlink folder from Windows

I use WSL almost exclusively, and only switch to main windows for browsing and running Windows native programs. I have a git repository located at /mnt/c/myrepo. In order to "install" the code inside /mnt/c/myrepo I need to move it to /mnt/c/otherlocation/renamed. Instead of executing cp -r /mnt/c/myrepo /mnt/c/otherlocation/renamed every time I do a git pull from /mnt/c/myrepo, I would like to symlink /mnt/c/myrepo to /mnt/c/otherlocation/renamed. However when I do this, the program which consumes /mnt/c/otherlocation/renamed isn't able to view the "contents" of renamed as a directory.
I have been all over the WSL github repo and issue tracker trying to find a solution to this issue. I see a lot of exclamations about how symlinks "just work". I have enabled every Windows 10 developer feature I can find, I even followed some reddit thread where someone claimed that purchasing Pengwin and creating a symlink from Pengwin would ensure this compatibility, but I still can't seem to make this work.
The basic usage I need, is allow me to view "renamed" as a directory from windows, or for windows to recognize the symlink as a symlinked directory.
from wsl:
ln -s /mnt/c/myrepo /mnt/c/otherlocation/renamed
from windows:
open file explorer
navigate to c:\otherlocation
open mydir and view the contents as if it were a native directory
How do I do this?
Do the symlink in Windows, in cmd.exe:
mklink /d C:\otherlocation\renamed C:\myrepo
It doesn't make sense creating the symlinks in WSL if both directories are in Windows.
This symlink will work in WSL as well.
The solution to this problem is simply to use the relative path when declaring the link. If you want to link from windows to windows, you should relatively path from the current directory and then you can link anywhere you wish.
From the example, instead of this:
ln -s /mnt/c/myrepo /mnt/c/otherlocation/renamed
Do this:
cd /mnt/c/otherlocation
ln -s ../../myrepo ./renamed

Make link to Application folder

Sublime Text editor has in DMG file link to Applications dir (blue icons with arrow). It has small size.
How to make such link on my own folder? It must work in all Macs.
Open the terminal, use cd to open the folder where you want to create the symbolic link (this is how that kind of link is called, in case you want to research a bit more about it). Example:
cd /Users/MyUser/Desktop/
Note: In case the path has spaces, write it with backslashes before each space, like that:
cd /Users/MyUser/Desktop/My\ Folder/
Then, use that command to create it:
ln -s /Applications/ Applications
It will create a symbolic link which opens the path /Applications/, which means that it will work in any macOS computer.
Reference:
https://apple.stackexchange.com/a/115648

Is it possible to create multiple references to a file on Macintosh?

What I mean is that I want the same file to exist in 2 different locations, so that when I save it in 1 location it updates in the other location. I'm running OSX Yosemite, btw. Is this possible?
If you're looking to have the file on the same computer, a symlink will do the trick:
Fire up terminal
Navigate to the directory you want to have the symlink in cd /path/to/your/file
do ln -s /any/file/on/the/disk linked-file where "linked-file" will be the name of the file you want
If you're looking to have the file on a separate computer or on a network drive, you should probably look into rsync.

IS there any way to add an alias to the user Documents folder inside a DMG

It is easy enough to add an alias to the Applications folder inside a DMG as it is at /Applications on every Mac. But is it possible to add an alias to a user's Documents folder, where the Documents folder has a different path for each user? I tried adding an alias to ~/Documents, but it became an alias to /Users/andyb/Documents, which obviously won't work on anyone else's machine.
You cannot use a symbolic link to the users Documents directory since you don't know the path. The '~' as an abbreviation to the home directory cannot be used in a symbolic link because there's no shell that would resolve it.
Alias Files can only be created by the Finder (there's no API for that in Mac OS X), so if an Alias File from the Finder is not working, then there's no way.
I'm afraid, the answer is no.

Resources