How to create a bash/zsh status bar on macOS

For zsh, just add this to your .zshrc file:

zmodload zsh/terminfo
autoload -Uz add-zsh-hook
statusbar () {
  echoti sc                   # Save cursor position.
  echoti home                 # Move cursor to top left of window.

  # -n: Don't append a newline.
  # -P: Expand prompt escape codes.
  print -nP -- "[$( git branch --show-current 2> /dev/null )]($VIRTUAL_ENV)%n@%M:%~"

  echoti el                   # Clear to end of line
  echoti rc                   # Restore cursor position.
}
add-zsh-hook precmd statusbar # Call before each new prompt.