zsh prompt: match git dir by index rather than text

otherwise we could end up with repeated directory names not being
collapsed.