dots status should correctly detect the status of a package that isn't a Git repo

This commit is contained in:
Danielle McLean 2016-10-11 20:07:22 +11:00
parent 82d27231b1
commit c74b8ba141
No known key found for this signature in database
GPG key ID: CC91589719027E94

View file

@ -69,12 +69,15 @@ status() {
local -a packages local -a packages
packages=($argv) packages=($argv)
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) ) (( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
local length=${#${(O@)packages//?/X}[1]} local length=${#${(O@)packages//?/X}[1]} git_status
cd $DOTFILES cd $DOTFILES
for p in $packages; do for p in $packages; do
pushd $p pushd $p
printf "%${length}s " $p printf "%${length}s " $p
if [[ -z "$(command git status --porcelain --ignore-submodules -unormal)" ]]; then git_status="$(command git status --porcelain --ignore-submodules -unormal 2>/dev/null)"
if (( $? != 0 )); then
print -P "%F{247}not a git repository%f"
elif [[ -z $git_status ]]; then
print -P "%F{green}clean%f" print -P "%F{green}clean%f"
else else
print -P "%F{red}unclean%f" print -P "%F{red}unclean%f"