sindresorhus / pure

Pretty, minimal and fast ZSH prompt
MIT License
13.22k stars 978 forks source link

Monitor the value of environment variables #624

Closed benozol closed 2 years ago

benozol commented 2 years ago

pure is really nice, thanks!

this PR allows to monitor the value of environment variables with pure. I found it quite useful when working with commands that use environment variables.

image

mafredri commented 2 years ago

@benozol I think this use-case is a bit too specific for Pure. We can revisit this if more people find it useful. Thanks for thinking of us and submitting a PR though!

You could also achieve this without modifying Pure, using e.g. RPROMPT.

monitor() {
    for var in $PURE_MONITOR_VARIABLES; do
        if [[ -n "${(P)var}" ]]; then
            preprompt_parts+=" $var=${(P)var}"
        fi
    done
}
RPROMPT='$(monitor)'
~
❯ PURE_MONITOR_VARIABLES=(var1)

~
❯ var1=hello

~
❯                                  var1=hello
benozol commented 2 years ago

trying to upstream my config – and getting a much better solution… thanks!