Distinguish between focused and unfocused clients in Tmux

Although tmux highlights active pane’s borders and even lets to customize them via pane-active-border-style option, it’s sometimes more desirable to instantly distinguish between focused and unfocused clients, as tiny borders are not so visible. Here is a script to achieve this via toggling status line background color:

# StatusLine face toggle
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
declare-option -hidden str last_focus_in
declare-option -hidden str focus_out_face "rgb:FDFDFD,rgb:8e908c"
hook global -group status-line-face-toggle FocusIn .* %{
    set-option global last_focus_in %val{client}
    unset-face window StatusLine
    evaluate-commands %sh{
        for client in $kak_client_list; do
            if [ "$client" != "$kak_hook_param" ]; then
                printf "eval -no-hooks -client %s 'set-face window StatusLine %s'\n" \
                "$client" "$kak_opt_focus_out_face"
            fi
        done
    }
}

hook global -group status-line-face-toggle WinDisplay .* %{
    evaluate-commands %sh{
        if [ "$kak_client" == "$kak_opt_last_focus_in" ]; then
            echo "unset-face window StatusLine"
        elif [ -n "$kak_opt_last_focus_in" ]; then
            printf "set-face window StatusLine %s\n" "$kak_opt_focus_out_face"
        fi
    }
}

I think this is applicable not only to tmux, but any windows manager supported by kakoune.

Relevant discussion

1 Like

I simply use

set -g window-style 'fg=colour252,bg=colour240'
set -g window-active-style 'fg=colour250,bg=colour235'

colour schemes will vary but this makes inactive panels a light grey and the active panel dark grey/black. might also need to make sure that your base faces like Default and BufferPadding use default as their bg colour.