Skip to content

Instantly share code, notes, and snippets.

@nkh
Created July 26, 2023 11:47
Show Gist options
  • Save nkh/75bd5ab4dd98651a4b3d657b4b14339b to your computer and use it in GitHub Desktop.
Save nkh/75bd5ab4dd98651a4b3d657b4b14339b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
declare -A git_status
while IFS= read -r -d $'\0' line ; do git_status[${line:3}]="${line:0:2}" ; done < <(git status $@ --porcelain -z)
while IFS= read line ; do [ ! "${git_status[$line]}" ] && git_status[$line]=" " ; done
for file in "${!git_status[@]}" ; do
echo "$file" >&3
echo "${git_status[$file]}" >&4
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment