username_span    = { "\\{username}" }
hostname_span    = { "\\{hostname}" }
current_dir_span = { "\\{current_dir}" }
repo_status_span = { "\\{repo_status}" }
reset_span       = { "\\{reset}" }
bold_span        = { "\\{bold}" }
underline_span   = { "\\{underline}" }
red_span         = { "\\{red}" }
blue_span        = { "\\{blue}" }
green_span       = { "\\{green}" }
yellow_span      = { "\\{yellow}" }
cyan_span        = { "\\{cyan}" }
magenta_span     = { "\\{magenta}" }
newline_span     = { "\\n" }

condition = {
    "in_repo"
}
if_span = { "\\if{" ~ condition ~ "}" ~ "{" ~ prompt ~ "}" ~ "{"~ prompt ~ "}" }

special_span = _{
    username_span
    | hostname_span
    | current_dir_span
    | repo_status_span
    | newline_span
    | reset_span
    | bold_span
    | underline_span
    | red_span
    | blue_span
    | green_span
    | yellow_span
    | cyan_span
    | magenta_span
    | if_span
}

literal_span = ${ (!(special_span | "}") ~ ANY)+ }
prompt = ${ (special_span | literal_span)* }
