Different between `set -g` and `setw -g` and `set`?

Solution 1:

The link provided by StevieD "Possible duplicate of Difference between global, server, session and window options" is a great overview.

Basically, it's complicated. "set" can set server, window, and session options, and will work the same to set a server option with "set -s" or "set". However, it's good practice to include the "-s" when setting a server options because it prevents setting the option if it's not actually a server option. Examples of server options include buffer-limit and exit-unattached. If you use set -s to edit an option, then open a new terminal, the new terminal will reflect the changed option.

The "setw" command has less flags that can be used with it. "setw -s" doesn't make any sense because setw is specific to the window. (By the way, "set -w" is the exact same as "setw".) Similarly to the "set" command, -a appends the value to the existing setting, -F expands formats in the option value, -g sets/unsets a global option, -o prevents setting an option that's already set, -q suppresses errors about unknown or ambiguous options, and -u unsets an option so that a session inherits from the global options or if -g is also used then it actually changes that global option back to default.

So if I want to just change ONLY MY WINDOW's default shell to /bin/bzexe, I can run tmux setw default-shell /bin/bzexe

"set" sets an option which will remain unchanged when "set -g" is run. "setw" has different options from "set" and "setw -g" acts similarly to "set -g" in that setting that global will not change the value when checked with "show-window-option".

"set" options can be shown with "show-options" "setw" options can be shown with "show-window-option" All the above commands can be altered to instead look at the globals by adding a -g.