Repository: nicolodiamante/icloud-nosync Branch: main Commit: 84f46c94bccb Files: 10 Total size: 24.5 KB Directory structure: gitextract_8ngt5gwz/ ├── .gitignore ├── LICENSE.md ├── README.md ├── bootstrap.zsh ├── scripts/ │ ├── iCloud No Sync.workflow/ │ │ └── Contents/ │ │ ├── Info.plist │ │ └── document.wflow │ └── iCloud Sync.workflow/ │ └── Contents/ │ ├── Info.plist │ └── document.wflow └── utils/ ├── install.zsh └── uninstall.zsh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # # Ignore # *.swp .DS_Store ================================================ FILE: LICENSE.md ================================================ The MIT License (MIT) © 2024 Nicolò Diamante Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================

iCloud NoSync

[iCloud][apple-icloud] is a powerful utility that allows users to sync files across multiple devices. However, sometimes users may want to prevent certain files or folders from syncing. Apple has a blacklist of file names and extensions that users should avoid using in their iCloud Drive. Adding the extension .nosync to a file is a simple way to prevent iCloud from syncing that file. This technique is useful for selective syncing. However, adding the same extension to a folder will not prevent iCloud from syncing its contents. The only way to prevent an entire folder from syncing is to name it tmp or end it with .tmp.

iCloud NoSync Finder



**iCloud No Sync:** hides and appends the appropriate extension to the file or folder, effectively stopping the sync process. It then creates a symbolic link with the same name as the original file or folder to avoid any issues with applications that depend on it.
**iCloud Sync:** it first unhides the original file or folder. Then, it removes the symbolic link and the extension to restart the synchronisation. This means that iCloud Sync always refers to the symlink to restart the sync, which ensures that the latest version of the file or folder is synchronised across all your devices. By removing the symbolic link and the extension, iCloud Sync ensures that the sync is done from scratch, which reduces the chances of any errors or conflicts during the synchronisation process.

## Getting Started ### Installation The installation process for this utility is designed for ease and convenience. You have two options: **Automatic Installation via `curl`**: Simply execute the following command in your terminal to quickly download and seamlessly install the utility: ```shell zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/icloud-nosync/HEAD/bootstrap.zsh)" ``` **Manual Installation**: If you favor manual installation, first clone the repository to your local machine using `git`: ```shell git clone https://github.com/nicolodiamante/icloud-nosync.git ``` After cloning, navigate to the repository's directory in your terminal and execute the install script: ```shell source utils/install.zsh ``` The script will copy the workflow files to `~/Library/Services` and then open the Privacy & Security panel.
### Show in Quick Action Menu Once the script opens the Privacy & Security panel, select Finder and check the boxes:

Selected Quick Actions



After doing this, you should be able to right-click on files or folders in Finder and find the `iCloud No Sync` and `iCloud Sync` options in the Quick Action section of the context menu.
## How It Works 1. Right-click on the file or folder you want to stop syncing to iCloud Drive. 2. Select `iCloud No Sync` from the `Quick Actions` menu to stop the sync. 3. Select `iCloud Sync` from the `Quick Actions` menu to sync it again.

Quick Actions Menu


## Notes ### Resources - [Apple Support][apple-guide] ### Contribution Any suggestions or feedback you may have for improvement are welcome. If you encounter any issues or bugs, please report them to the [issues page][issues].

Nicolò Diamante Portfolio

MIT License

[apple-icloud]: https://www.apple.com/icloud/ [apple-guide]: https://support.apple.com/guide/mac-help/get-file-folder-and-disk-information-on-mac-mchlp1774/11.0/mac/11.0 [issues]: https://github.com/nicolodiamante/icloud-nosync/issues ================================================ FILE: bootstrap.zsh ================================================ #!/bin/zsh # # Start iCloud NoSync Installation. # # Validate OS. if [[ "$OSTYPE" != "darwin"* ]]; then echo "This script is only compatible with macOS" >&2 exit 1 fi # Defines the PATHs. SOURCE="https://github.com/nicolodiamante/icloud-nosync" TARBALL="${SOURCE}/tarball/master" TARGET="${HOME}/icloud-nosync" TAR_CMD="tar -xzv -C \"${TARGET}\" --strip-components 1 --exclude .gitignore" INSTALL="${TARGET}/utils/install.zsh" # Check if a command is executable. is_executable() { command -v "$1" &> /dev/null } # Checks which executable is available then downloads and installs. if is_executable "git"; then CMD="git clone ${SOURCE} ${TARGET}" elif is_executable "curl"; then CMD="curl -L ${TARBALL} | ${TAR_CMD}" elif is_executable "wget"; then CMD="wget --no-check-certificate -O - ${TARBALL} | ${TAR_CMD}" else echo 'No git, curl, or wget available. Aborting!' exit 1 fi echo 'Installing iCloud NoSync...' # Create the target directory and proceed with the chosen download method. if ! mkdir -p "${TARGET}"; then echo "Error: Failed to create target directory. Aborting!" >&2 exit 1 fi # Execute the download command and run the installation script. if eval "${CMD}"; then if cd "${TARGET}"; then if ! source "${INSTALL}"; then echo "Error: Failed to run the install script. Aborting!" >&2 exit 1 fi else echo "Error: Failed to navigate to ${TARGET}. Aborting!" >&2 exit 1 fi else echo "Download failed. Aborting!" >&2 exit 1 fi ================================================ FILE: scripts/iCloud No Sync.workflow/Contents/Info.plist ================================================ NSServices NSBackgroundColorName background NSIconName NSTouchBariCloud NSMenuItem default iCloud No Sync NSMessage runWorkflowAsService NSRequiredContext NSApplicationIdentifier com.apple.finder NSSendFileTypes public.item ================================================ FILE: scripts/iCloud No Sync.workflow/Contents/document.wflow ================================================ AMApplicationBuild 509 AMApplicationVersion 2.10 AMDocumentVersion 2 actions action AMAccepts Container List Optional Types com.apple.cocoa.string AMActionVersion 2.0.3 AMApplication Automator AMParameterProperties COMMAND_STRING CheckedForUserDefaultShell inputMethod shell source AMProvides Container List Types com.apple.cocoa.string ActionBundlePath /System/Library/Automator/Run Shell Script.action ActionName Run Shell Script ActionParameters COMMAND_STRING NAME="$1" FILE_NAME="${NAME}.nosync" DIR_NAME="${NAME}.tmp" if [ -d "$1" ]; then mv "${NAME}" "${DIR_NAME}" && ln -s "${DIR_NAME}" "${NAME}" && chflags hidden "${NAME}" elif [ -f "$1" ]; then mv "${NAME}" "${FILE_NAME}" && ln -s "${FILE_NAME}" "${NAME}" && chflags hidden "${NAME}" fi CheckedForUserDefaultShell inputMethod 1 shell /bin/sh source BundleIdentifier com.apple.RunShellScript CFBundleVersion 2.0.3 CanShowSelectedItemsWhenRun CanShowWhenRun Category AMCategoryUtilities Class Name RunShellScriptAction InputUUID C1FF256B-B0E9-49B3-9B29-1EAC33F28FAF Keywords Shell Script Command Run Unix OutputUUID 48CF9AED-0B52-4174-A385-9CA96C043332 UUID B28FCA34-9B06-42EC-B7EE-F8618598FA2C UnlocalizedApplications Automator arguments 0 default value 0 name inputMethod required 0 type 0 uuid 0 1 default value name CheckedForUserDefaultShell required 0 type 0 uuid 1 2 default value name source required 0 type 0 uuid 2 3 default value name COMMAND_STRING required 0 type 0 uuid 3 4 default value /bin/sh name shell required 0 type 0 uuid 4 isViewVisible location 671.500000:305.000000 nibPath /System/Library/Automator/Run Shell Script.action/Contents/Resources/Base.lproj/main.nib isViewVisible connectors workflowMetaData applicationBundleID com.apple.finder applicationBundleIDsByPath /System/Library/CoreServices/Finder.app com.apple.finder applicationPath /System/Library/CoreServices/Finder.app applicationPaths /System/Library/CoreServices/Finder.app inputTypeIdentifier com.apple.Automator.fileSystemObject outputTypeIdentifier com.apple.Automator.nothing presentationMode 15 processesInput 0 serviceApplicationBundleID com.apple.finder serviceApplicationPath /System/Library/CoreServices/Finder.app serviceInputTypeIdentifier com.apple.Automator.fileSystemObject serviceOutputTypeIdentifier com.apple.Automator.nothing serviceProcessesInput 0 systemImageName NSTouchBariCloud useAutomaticInputType 0 workflowTypeIdentifier com.apple.Automator.servicesMenu ================================================ FILE: scripts/iCloud Sync.workflow/Contents/Info.plist ================================================ NSServices NSBackgroundColorName background NSIconName NSTouchBariCloud NSMenuItem default iCloud Sync NSMessage runWorkflowAsService NSRequiredContext NSApplicationIdentifier com.apple.finder NSSendFileTypes public.item ================================================ FILE: scripts/iCloud Sync.workflow/Contents/document.wflow ================================================ AMApplicationBuild 492 AMApplicationVersion 2.10 AMDocumentVersion 2 actions action AMAccepts Container List Optional Types com.apple.cocoa.string AMActionVersion 2.0.3 AMApplication Automator AMParameterProperties COMMAND_STRING CheckedForUserDefaultShell inputMethod shell source AMProvides Container List Types com.apple.cocoa.string ActionBundlePath /System/Library/Automator/Run Shell Script.action ActionName Run Shell Script ActionParameters COMMAND_STRING TEMP="$(readlink "$1")" if [[ -L "$1" ]]; then rm -rf "$1" && cp -rf "${TEMP}" "$1" && rm -rf "${TEMP}" fi CheckedForUserDefaultShell inputMethod 1 shell /bin/sh source BundleIdentifier com.apple.RunShellScript CFBundleVersion 2.0.3 CanShowSelectedItemsWhenRun CanShowWhenRun Category AMCategoryUtilities Class Name RunShellScriptAction InputUUID 7D0D2AF0-F6C0-4EAC-AF4D-C5CCD5F16301 Keywords Shell Script Command Run Unix OutputUUID B765991D-EFFE-419E-8534-BF253C123C9A UUID 9F187A6A-053D-47B4-88F8-37AE5A9CC4EB UnlocalizedApplications Automator arguments 0 default value 0 name inputMethod required 0 type 0 uuid 0 1 default value name CheckedForUserDefaultShell required 0 type 0 uuid 1 2 default value name source required 0 type 0 uuid 2 3 default value name COMMAND_STRING required 0 type 0 uuid 3 4 default value /bin/sh name shell required 0 type 0 uuid 4 isViewVisible location 624.750000:305.000000 nibPath /System/Library/Automator/Run Shell Script.action/Contents/Resources/Base.lproj/main.nib isViewVisible connectors workflowMetaData applicationBundleID com.apple.finder applicationBundleIDsByPath /System/Library/CoreServices/Finder.app com.apple.finder applicationPath /System/Library/CoreServices/Finder.app applicationPaths /System/Library/CoreServices/Finder.app inputTypeIdentifier com.apple.Automator.fileSystemObject outputTypeIdentifier com.apple.Automator.nothing presentationMode 15 processesInput 0 serviceApplicationBundleID com.apple.finder serviceApplicationPath /System/Library/CoreServices/Finder.app serviceInputTypeIdentifier com.apple.Automator.fileSystemObject serviceOutputTypeIdentifier com.apple.Automator.nothing serviceProcessesInput 0 systemImageName NSTouchBariCloud useAutomaticInputType 0 workflowTypeIdentifier com.apple.Automator.servicesMenu ================================================ FILE: utils/install.zsh ================================================ #!/bin/zsh # # Install iCloud NoSync. # # Detects the Operating System if [[ "$OSTYPE" != "darwin"* ]]; then echo "This script is only compatible with macOS" >&2 exit 1 fi # Define the Services directory APPLE_SERVICES="${HOME}/Library/Services" # Detects which macOS version SW_VERS=$(sw_vers -buildVersion) OS_VERS=$(sed -E -e 's/([0-9]{2}).*/\1/' <<< "$SW_VERS") if [[ "$OS_VERS" -ge 14 ]]; then echo "\niCloud NoSync: Starting the installation process..." # Copies files into the Services directory using the absolute path. if cp -r "${0:A:h}/../scripts/iCloud No Sync.workflow" "${APPLE_SERVICES}" && \ cp -r "${0:A:h}/../scripts/iCloud Sync.workflow" "${APPLE_SERVICES}"; then echo "iCloud NoSync: The workflow files have been copied into the Services directory." echo "\niCloud NoSync: Opening the Privacy & Security Panel in System Settings..." sleep 2 && open "x-apple.systempreferences:com.apple.preferences.extensions" # Guide the user to enable the Quick Actions in Finder. echo "\niCloud NoSync: From the Privacy & Security Panel open Finder." echo "iCloud NoSync: Check 'iCloud No Sync' and 'iCloud Sync' Quick Actions." else echo "iCloud NoSync: Error occurred while copying the workflow files." >&2 exit 1 fi else echo "\niCloud NoSync:" echo "Looks like this Mac is running an earlier version of macOS. " echo "To be able to use and sync files, iCloud Drive requires " echo "OS X Yosemite 10.10 or a later version of system software. " echo "Please visit: https://support.apple.com/en-us/HT204025 " fi ================================================ FILE: utils/uninstall.zsh ================================================ #!/bin/zsh # # Uninstall iCloud NoSync. # # Detects the Operating System. if [[ "$OSTYPE" != "darwin"* ]]; then echo "This script is only compatible with macOS" >&2 exit 1 fi echo "\niCloud NoSync: Starting the removal process..." # Defines the Services directory and the workflow files. APPLE_SERVICES="${HOME}/Library/Services" NO_SYNC=iCloud\ No\ Sync.workflow SYNC=iCloud\ Sync.workflow # Removes workflow files inside the Services directory. for file in "${APPLE_SERVICES}"/{"$NO_SYNC","$SYNC"}; do [[ -r "$file" ]] && rm -rf "${file}" done # Prints a success message. echo "iCloud NoSync: The workflow files have been removed."