Ok, I figured it out.
The problem lies in the fact that you are obligated to use the -g (global) flag when specifying a window-status in .tmux.conf.
.tmux.conf:
WINDOW="[#I #20W]"
set-window -g window-status-current-format $WINDOW
set-window -g window-status-format $WINDOW
The key is to make the status local after creating a window. Also, each window needs to be uniquely identifiable. Luckily this can be done by tmux variable 'window_id'. A small script, shown below, will output a variable unique to the window with this id as its first argument:
~/tmuxstatus:
#!/bin/bash
VARIABLE="W_$1"
VALUE=$(tmux show-environment -g $VARIABLE 2>&1)
VALUE=${VALUE#*=}
echo $VALUE
There is probably a TMUX only solution to make the status local, but I don't currently have the time. I'm using bash to do it with the aid of the environment variable PROMPT_COMMAND, which is evaluated just before the prompt is shown.
.bashrc:
function __prompt_command (){
if [ -n "$TMUX" ] && [ ! -n "$TMUX_INIT" ]; then
W=$(tmux display -p '#{window_id}')
VARIABLE="W_$W"
VALUE="value_$W"
STATUS="[#I #(~/tmuxstatus $W)]"
tmux set-option quiet on;
tmux set-environment -g $VARIABLE $VALUE;
tmux set-window window-status-current-format "$STATUS";
tmux set-window window-status-format "$STATUS";
export TMUX_INIT="done";
fi;
}
export PROMPT_COMMAND=__prompt_command
When changing the value of W_id, the window status changes also. It looks like:
[1 value_@0] [2 value_@1] [3 value_@2] [4 value_@3]
enjoy!