Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove color codes, use zstyle/zformat #7

Open
cdlm opened this issue Jul 16, 2011 · 1 comment
Open

Remove color codes, use zstyle/zformat #7

cdlm opened this issue Jul 16, 2011 · 1 comment

Comments

@cdlm
Copy link

cdlm commented Jul 16, 2011

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
@michaelbarton
Copy link

This was very useful. I have remodelled my prompt based on this. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants