I'd like to see the current commit hash (just the first 8 or so characters) in my zsh prompt.
I have this so far: https://github.com/calebmeyer/cpm-zsh-theme/blob/master/cpm.zsh-theme#L3
git_commit_hash() {
if [ -d .git ]; then
git log -1 --pretty=oneline | cut -c -8
fi
}
When I source the file, (via . ./cpm.zsh-theme
), I see the commit hash for the current commit. However, it doesn't update when I change directories or make changes/commits. This also means that when I load up the theme on prompt start, there's no commit hash (and that never updates)
How can I get zsh to re-evaluate this function on every new prompt?
Note: I'm using oh-my-zsh and antigen to manage my config. You can see my dotfiles here: https://github.com/calebmeyer/dotfiles