|al(j)ʊˈmɪnɪəm| mass noun - the chemical element of atomic number 13, a corrosion-resistant metal named after Habib Alamin, a computer programmer

How to change the current session's working directory in tmux 1.9+

tmux 1.9 dropped support for the default-path option that determines the working directory for new panes (which obviously works with windows, as they all have at least one pane). This is extremely inconvenient if you often start a tmux session, then realise you actually wanted to start a directory higher (you want to generalise the work you're doing in that session). By the time you realise, you may already have a bunch of splits and windows open with programs running.

Most people on Stack Overflow and around the net seem to be satisfied with opening new panes with the same working directory as the pane they were already in. This is not only an unsatisfactory result for me, but it also seems to require rebinding the default keys to add the -c option with "$PWD" or "#{pane_current_path}". I like the default behaviour of starting all panes in the same default session directory, but I want the ability to change that directory after I've started the session.

Well, it turns out you can attach to a session and specify the directory for that session as an option when you attach. If you don't know, all the tmux commands you can run from the command line are simply the same commands you can run from the session itself with the tmux command prompt. I found that attach-session from the tmux command prompt just attached you to the same session you were already in, which was essentially a no-op (as you are already attached to the session you are in by definition).

Put all that together, and what it means is that you can say attach-session -c "$SOME_DIRECTORY" to change the working directory of the session as a whole. Any new panes should now open in that directory that you specified. To me, that's just as good as set -g default-path "$SOME_DIRECTORY", 'cept a little less obvious.

It took me months to discover this, so I hope this proves useful to someone.