Im gonna not read anything above and say handsoap, a very thin layer of handsoap will prevent fogging and wont cause any visual distortion or gunk. Used to do it all the time in college.
foam canned shaving cream works really well. just squirt some smear it over the mirror, and wipe it off. doing this once a week or so keeps my bathroom mirror completely fog free
When I used to shave in the shower, the Rain X anti fog stuff worked on the little mirror I had in the shower. But, I don't think it was glass like a mirror on the bath wall or in a medicine chest.
tried the shaving cream trick today (had some canned foam from the old days under the counter). Wiped a little bit over the mirror and wiped it off with a clean towel. Tested it tonight, no fog after my shower. Didn't need to shave but it worked great, i'll use this tip from here on. Thanks