Terminal "osascript -e" commands
osascript is a tool to execute AppleScript within a shell/script.

Here is Apple's introductory guide:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html

Additionally, you can open Script Editor.app (in /Applications/Utilities if your on OS X 10.11).  From the menu bar select Window > Library to browse library documentation.