Resulting zsh prompt displaying a “WIP COMMITS IN BRANCH”

By editing ~/.p10k.zsh you can add more infos to your prompt. In my case, to achieve the above result, I added the following function to the file (after prompt_example):

  function prompt_git_wip() {
    # check that we are in a git repository
    git rev-parse --is-inside-work-tree &>/dev/null || return

    keyword="wip"
    branch=$(git rev-parse --abbrev-ref HEAD)
    git log master..$branch --grep="$keyword" --quiet | grep "$keyword" > /dev/null
    
    if [ $? -eq 0 ]; then
      p10k segment -f 208 -i '⚠️' -t "WIP COMMITS IN BRANCH"
    fi
  }

  function instant_prompt_git_wip() {
    prompt_git_wip
  }

In the same file, the “extension” then need to be enabled:

typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
    [REDACTED]
    # =========================[ Line #2 ]=========================
    newline                 # \n
    # ip                    # ip address and bandwidth usage for a specified network interface
    # public_ip             # public IP address
    # proxy                 # system-wide http/https/ftp proxy
    # battery               # internal battery
    # wifi                  # wifi speed
    # example               # example user-defined segment (see prompt_example function below)
    git_wip
  )

I chose to have mine at the end of the second line, but you can place it anywhere you want.

Powerlevel10k