dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 73a3c68ac1aca4cfbe7b624dafbc4b028446e04c
parent 837893efad70d9e4e0c8a8b1ef76e76631b01baf
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Tue, 17 Sep 2019 20:58:55 -0400

shrc: Better git rev-parsing

Diffstat:
M.shrc | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/.shrc b/.shrc @@ -19,11 +19,9 @@ __ps1() { then if git rev-parse --show-toplevel > /dev/null 2>&1 then - gitref=$(git rev-parse --abbrev-ref HEAD) - if [ $gitref = HEAD ] - then - gitref=\($(git rev-parse --short HEAD)\) - fi + gitref=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) + [ $? -ne 0 ] && gitref="GIT: empty" + [ "$gitref" = HEAD ] && gitref=\($(git rev-parse --short HEAD)\) echo " ($gitref)" else echo