Skip to content

Remove color codes, use zstyle/zformat #7

@cdlm

Description

@cdlm

Hi, as said in your TODO file, you have yet another implementation of ansi-color sequences in prompt_wunjo_setup. Using tput would indeed be nice, but I think it should be the responsability of someone refactoring the colors module.

For your prompt, using zstyle and zformat seems more to the poinf, as it would allow users to organize the whole messages (and display colors as they like). For instance, I like minimal prompts, so I'd prefer limit git information to short symbols about the branch and dirty status.

I took the liberty of adapting your prompt_wunjo_scm_branch function for my own use, and here's what it looks like:

function promptinfo_git_status() {
   zgit_isgit || return
   local msg

   if zgit_inworktree; then
      local fmt
      zstyle -s ':promptinfo:' git-status fmt
      [[ -z ${fmt} ]] && fmt='%(i.-.+)%(w.-.*)%(m.!.-)%(t.?.-)'

      zformat -f msg ${fmt} \
         i:$(status zgit_isindexclean) \
         w:$(status zgit_isworktreeclean) \
         m:$(status zgit_hasunmerged) \
         t:$(status zgit_hasuntracked)
   fi
   echo -n ${msg}
}

function status() { "$@"; echo $? } # needed because your functions don't echo anything themselves

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions