How can I script inverting screen colors?
If it's okay to give Terminal.app permanent access to Accessibility:


Open System Preferences
Go to Security &amp; Privacy section
In Privacy tab, click on the lock in bottom left and enter your password to enable editing
Select Accessibility from left side list and then check Terminal checkbox in right side list (if there is no Terminal checkbox here you might run step 5 once and then back to this step)
Open Terminal and run this line (it uses AppleScript):

 osascript -e "tell application \"System Preferences\"" -e "activate" -e "reveal anchor \"Seeing_Display\" of pane id \"com.apple.preference.universalaccess\"" -e "tell application \"System Events\" to tell process \"System Preferences\"" -e "click the checkbox \"Invert colors\" of window \"Accessibility\"" -e "end tell" -e "quit" -e "end tell"


repeating previous steps for the future is not needed.

If it's not okay to give direct access:


Open System Preferences
Go to Keyboard section
In Shortcuts tab, Select Accessibility from left side list and then check Invert colors in right side list (Default shortcut is ctrl+alt+cmd+8).
Open Terminal and run this line (it uses AppleScript):

 osascript -e "tell application \"System Events\"" -e "key code 28 using {control down, option down, command down}" -e "end tell"


repeating previous steps for the future is not needed.



You can write those codes in external script files and run with osascript invertColors.scpt