From 3dfa00942d34f8dccfae83860de2e7bf0cc2b708 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Tue, 12 Jul 2022 19:48:45 +0100
Subject: [PATCH] chore(zsh): update prompt

Ensure that the branch name and commit SHA update without needing to
source the config file again.
---
 roles/zsh/files/config/configs/prompt.zsh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/roles/zsh/files/config/configs/prompt.zsh b/roles/zsh/files/config/configs/prompt.zsh
index 3ac57cf5..46e359e7 100644
--- a/roles/zsh/files/config/configs/prompt.zsh
+++ b/roles/zsh/files/config/configs/prompt.zsh
@@ -1,15 +1,15 @@
-source $ZDOTDIR/oh-my-zsh/git.zsh
+setopt prompt_subst
 
-git_prompt_prefix() {
-  local tag="$(git describe --tags 2> /dev/null)"
+git_branch() {
+  local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)"
 
-  [ -n "${tag}" ] && echo "%{$fg[yellow]%}${tag}%{$reset_color%} "
+  [ -n "${branch}" ] && echo " (${branch})"
 }
 
-git_prompt_suffix() {
-  local branch="$(git_current_branch)"
+git_commit() {
+  local commit_sha="$(git rev-parse --short HEAD 2> /dev/null)"
 
-  [ -n "${branch}" ] && echo " on %{$fg[green]%}${branch}%{$reset_color%}"
+  [ -n "${commit_sha}" ] && echo " [${commit_sha}]"
 }
 
-export PS1="$(git_prompt_prefix)in %{$fg[blue]%}%1d/%{$reset_color%}$(git_prompt_suffix) "
+export PS1='%{$fg[blue]%}%1d%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}%{$fg[yellow]%}$(git_commit)%{$reset_color%} $ '