# Customize prompt settings
# Usage: prompt-config [setting] [value]
# Examples:
#   prompt-config                    # Show current settings
#   prompt-config show_username false
#   prompt-config color_primary ff6b6b
#   prompt-config reset

function prompt-config
    if test (count $argv) -eq 0
        echo "Current prompt settings:"
        echo ""
        echo "Colors:"
        echo "  surface: $prompt_color_surface"
        echo "  primary: $prompt_color_primary"
        echo "  secondary: $prompt_color_secondary"
        echo "  tertiary: $prompt_color_tertiary"
        echo "  error: $prompt_color_error"
        echo "  primary_fixed: $prompt_color_primary_fixed"
        echo "  tertiary_fixed: $prompt_color_tertiary_fixed"
        echo ""
        echo "Behavior:"
        echo "  show_username: $prompt_show_username"
        echo "  show_time: $prompt_show_time"
        echo "  time_format: $prompt_time_format"
        echo "  dir_truncation: $prompt_dir_truncation"
        echo ""
        echo "Symbols:"
        echo "  prompt_symbol: $prompt_symbol"
        echo "  user_symbol: $prompt_user_symbol"
        echo ""
        echo "Usage: prompt-config <setting> <value>"
        echo "       prompt-config reset"
        return
    end

    if test "$argv[1]" = "reset"
        set -e prompt_color_surface
        set -e prompt_color_primary
        set -e prompt_color_secondary
        set -e prompt_color_tertiary
        set -e prompt_color_error
        set -e prompt_color_primary_fixed
        set -e prompt_color_tertiary_fixed
        set -e prompt_show_username
        set -e prompt_show_time
        set -e prompt_time_format
        set -e prompt_dir_truncation
        set -e prompt_symbol
        set -e prompt_user_symbol
        echo "Prompt settings reset."
        return
    end

    if test (count $argv) -lt 2
        echo "Usage: prompt-config <setting> <value>"
        return 1
    end

    set -l setting $argv[1]
    set -l value $argv[2..-1]
    set -l varname prompt_$setting

    set -U $varname $value
    echo "Set $setting = $value"
end

complete -c prompt-config -f
complete -c prompt-config -n __fish_use_subcommand -a "reset" -d "Reset to defaults"
complete -c prompt-config -n __fish_use_subcommand -a "show_username" -d "Show username (true/false)"
complete -c prompt-config -n __fish_use_subcommand -a "show_time" -d "Show time (true/false)"
complete -c prompt-config -n __fish_use_subcommand -a "time_format" -d "Time format (e.g. %H:%M)"
complete -c prompt-config -n __fish_use_subcommand -a "dir_truncation" -d "Directory truncation depth"
complete -c prompt-config -n __fish_use_subcommand -a "symbol" -d "Prompt symbol"
complete -c prompt-config -n __fish_use_subcommand -a "user_symbol" -d "Username icon"
complete -c prompt-config -n __fish_use_subcommand -a "color_surface" -d "Surface color"
complete -c prompt-config -n __fish_use_subcommand -a "color_primary" -d "Primary color"
complete -c prompt-config -n __fish_use_subcommand -a "color_secondary" -d "Secondary color"
complete -c prompt-config -n __fish_use_subcommand -a "color_tertiary" -d "Tertiary color"
complete -c prompt-config -n __fish_use_subcommand -a "color_error" -d "Error color"
