Get the current username using Applescript
For various reasons while creating Applescripts, I’ve had a need for the script to know which computer it was on, since I am writing scripts for several co-workers to use. The easiest way to do so for me was to use each computer’s username (the shortname OS X uses for the home directory). It’s a pretty easy thing to extract from the home path:
display dialog userHome
This has worked well for me to be able to purge the script’s property settings whenever the script gets passed on to someone else (otherwise it seems to keep the property assignments on the new computer as well. Also, it’s set up just in case I ever need to fork code for a particular user if their computer setup happens to have something that just won’t work with the way the rest of the other computers are set up (hopefully that will not be necessary, but you just never know).
edit:
Well as usual, there’s an easier way:
display dialog userHome

