Most apps have either “Zoom” or “Zoom Window” menu item, so type the following in the Terminal app:
defaults write NSGlobalDomain NSUserKeyEquivalents '{"Zoom" = "@^Z"; "Zoom Window" = "@^Z"; }'
That sets the keyboard shortcut to Cmd-Ctrl-Z for almost all apps. Hitting that key combination repeatedly will toggle between the full-screen and fit-to-content states.
Note: You will have to restart any running apps before the setting will take effect for them.

Jordan Liggitt is a