]>
git.r.bdr.sh - rbdr/dotfiles/blob - zsh/functions/check-repos.zsh
3 # Function to check status of a git repository
6 local relative_path
="${repo_path#$PWD/}"
8 pushd "$repo_path" >/dev
/null
10 print
-n "${relative_path}: "
12 local status_output
=$(git status --porcelain)
14 if [[ -z "$status_output" ]]; then
15 print
-P "%F{green}CLEAN%f"
22 # Check for untracked files (??), modified files (M or space+M), and staged files (non-? non-space in first column)
23 if echo "$status_output" | grep -q "^??"; then
24 messages
+=("%F{yellow}UNTRACKED%f")
26 if echo "$status_output" | grep -q "^.[M]" || echo "$status_output" | grep -q "^M"; then
27 messages
+=("%F{red}MODIFIED%f")
29 if echo "$status_output" | grep -q "^[^? ]"; then
30 messages
+=("%F{blue}STAGED%f")
33 print
-P "${(j: :)messages}"
38 local start_dir
="${1:-.}"
39 fd
-H -t d
'^\.git$' -x echo {} | sort | sed 's/\/\.git$//' | rg
-v "${SYNC_REPOS_IGNORE}" | while read -r repo_path
; do
40 check
-repo "$repo_path"