Last active
March 27, 2023 09:47
-
-
Save gabro/5883819 to your computer and use it in GitHub Desktop.
Github-like working directory history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILES=`git ls-tree --name-only HEAD .` | |
MAXLEN=0 | |
IFS=$(echo -en "\n\b") | |
for f in $FILES; do | |
if [ ${#f} -gt $MAXLEN ]; then | |
MAXLEN=${#f} | |
fi | |
done | |
for f in $FILES; do | |
str=$(git log -1 --pretty=format:"%C(green)%cr%Creset %x09 %C(cyan)%h%Creset %s %C(yellow)(%cn)%Creset" $f) | |
printf "%-${MAXLEN}s -- %s\n" "$f" "$str" | |
done |
I've modified this:
https://github.com/mzavoloka/gitls
change /bin/bash
to /bin/sh
for portability
change echo -en to printf for portability and functionality (most echo
implementations don't support -e
)
change the use of backticks to $() to be consistent.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@coldcandor sorry for the late response, but gist doesn't send out notifications :(
For the spacing, I agree it can be improved, I just admittedly never spent too much time on this.
I'll think of making this a full-fledged utility, rather than a gist, thanks for the feedback.