status is-interactive
or exit

type -q tide
or exit

function __tide_terminal_color_theme_changed --on-variable fish_terminal_color_theme
    contains -- $fish_terminal_color_theme dark light
    or return

    __tide_apply_terminal_appearance $fish_terminal_color_theme
    set -l apply_status $status

    test $apply_status -eq 2
    and return 2
    test $apply_status -eq 1
    and return 0

    functions -q _tide_cache_variables
    and _tide_cache_variables
    functions -q _tide_sub_reload
    and tide reload
    commandline --function repaint
end

__tide_terminal_color_theme_changed
