Skip to content

Instantly share code, notes, and snippets.

@ZwodahS
Created March 8, 2016 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZwodahS/4b53f5fb1312347f22e3 to your computer and use it in GitHub Desktop.
Save ZwodahS/4b53f5fb1312347f22e3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# git + ls
C_RED=$(tput setaf 1)
C_GREEN=$(tput setaf 2)
C_YELLOW=$(tput setaf 3)
C_BLUE=$(tput setaf 4)
C_MAGENTA=$(tput setaf 5)
C_CYAN=$(tput setaf 6)
C_WHITE=$(tput setaf 7)
C_CLEAR=$(tput sgr0)
IFS=""
ls -lh --color | while read LINE; do
if $(git rev-parse --git-dir >/dev/null 2>&1); then
FILE=$(echo $LINE | rev | cut -d ' ' -f 1 | rev | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
STATUS=$(git status -s $FILE | sed 's/^ *//g' | cut -d ' ' -f 1)
if [ "$STATUS" == "M" ]; then
AUGMENT="${C_RED}(modified)${C_CLEAR}"
elif [ "$STATUS" == "??" ]; then
AUGMENT="${C_YELLOW}(untracked)${C_CLEAR}"
else
AUGMENT="${C_WHITE}(no change)${C_CLEAR}"
fi
echo $LINE $AUGMENT
else
echo $LINE;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment