Search code examples
macospathbashicloud-drive

add icloud destination to path in terminal


I want to add destination of iCloud drive folder to PATH in terminal.
I tried to add this line to .bash_profile (that path works with cd command)

export PATH="~/Library/Mobile\ Documents/com~apple~CloudDocs/Scripts:$PATH"

and nothing happened. Even ...com\~apple\~CloudDocs... doesn't work.
After calling echo $PATH, there was added entire path to iCloud drive exactly how I wanted. But when I call any of scripts located in that path No such file or directory error occurs.
When I rewrite .bash_profile file to export export PATH="~/.Scripts:$PATH" and relocate scripts there, everything works.


Solution

  • After doing a little bash code analysis, it looks like if your path beings with ~, then any subsequent ~ in the path is affected.

    From tilde.c

    /* Scan through STRING expanding tildes as we come to them. */
    while (1)
    

    Instead of using ~/Library/...,

    try /Users/[user]/Library/...