Alias in bash to Change Directory
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.
Solution 1:
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:~$