A shortcut for Merge all Windows on macOS Sierra
Open  → System Preferences → Keyboard → Shortcuts → App Shortcuts.
Click the + to add a new shortcut.
Choose All Applications from the Application dropdown.
As the Menu Title, enter Merge All Windows (*see note at the bottom).
Input a key combination of your choice as the Keyboard Shortcut. I use Ctrl ^W.


Now all applications with a menu item called Merge All Windows will respond to that key combination, and collapse all your windows into one.

Starting with Sierra, it is also possible to open documents in new tabs rather than in new windows. This is enabled by going into  → System Preferences → Dock and setting Prefer tabs when opening documents to Always.

If you would like new Terminal sessions to open as new tabs as well, you can achieve this by placing a file named .bashrc in ~ (your Home folder), with the following line in it:

osascript -e 'tell application "System Events" to click menu item "Merge All Windows" of menu "Window" of menu bar 1 of process "Terminal"' &gt;/dev/null 2&gt;&amp;1

Note: Merge All Windows may differ based on your operating system's language. If you are not using the English (US) locale, open Finder, and click the Window menu to determine the name of that command in your locale.