As Apple replied to the ticket referenced in mattdwen's Open Radar link above, as of macOS Sierra 10.12,
you can no longer create items in /Volumes unless root.
Further, my best understanding of the AppleScript mount volume command is that it doesn't have a way to specify the mount point and consequently it only mounts volumes under /Volumes
through the Finder's standard mechanism. So, I don't think you can do it via AppleScript.
But there's another way. You can accomplish the same thing using the lower level mount
command:
mkdir -p ~/mnt
mount_smbfs "//my_username:my_password@my_hostname/share" ~/mnt
After mounting the volume this way, you should see a normal "volume" icon appear on your desktop and the ~/mnt
directory will appear as "share" when you browse your user directory via Finder.
The one thing missing from this approach is saving the login credentials in Keychain. To do that, you have to do a bit more scripting. Something like this.
Save the password:
security add-generic-password -a my_username -s my_hostname -w my_password
Retrieve the password and mount the share:
pass=$(security find-generic-password -a my_username -s my_hostname -w)
mount_smbfs "//my_username:${pass}@my_hostname/share" ~/mnt
NOTE: If you have special characters in your password, you will probably need to URL encode it, perhaps like this:
pass='my !@#%%^& password'
pass=$(php -r "echo urlencode(\"$pass\");")
>>> my+%21%40%23%25%25%5E%26+password
Sigh. Exploring my own situation further, I think I was hitting escape. I think zsh was in vi
mode all along, but more specifically, it was in vi's insert mode! If I go to a brand new editor and hit escape, I find myself in vi's command mode.
If that's the case, I'm still interested to know why set -o | egrep "on$"
doesn't indicate that we're in vi mode.
EDIT: double-sigh. I originally wrote my question with all references to bash, having completely forgotten that years ago I changed my default shell to zsh, which is mostly the same. I went back and edited the question to be more clear, and then googled again, replacing bash with zsh. I quickly found this: https://unix.stackexchange.com/questions/197839/why-does-exporting-vim-as-editor-in-zsh-disable-keyboard-shortcuts
Lo and behold, my .profile
has EDITOR=vi
, which I put there about two weeks ago. I removed that line, and hitting escape no longer puts me in vi command mode.
Better yet, I followed the instructions given on that answer and was able to restore my EDITOR setting without borking up zsh. Yay! :)
Best Answer
Running the following commands in macOS Catalina 10.15: