-
Notifications
You must be signed in to change notification settings - Fork 3
/
git-ltr
executable file
·40 lines (34 loc) · 879 Bytes
/
git-ltr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Lists (a-la 'ls -ltr') git controlled source files in current directory.
usage() {
(
echo "usage: ${0##*/} [-h|--help] [-r]"
echo "Lists (a-la 'ls -ltr') git controlled source files in current directory."
echo
echo "options:"
(
echo " -h, --help: show usage help"
echo " -r: recursive"
) | column -ts:
) >&2
exit 1
}
if echo "$*" | grep -Eq -- '--help\b|-h\b'; then
usage
fi
RECURSIVE=""
while getopts "r" opt; do
case "$opt" in
r) RECURSIVE="-r" ;;
*) usage ;;
esac
done
shift $((OPTIND - 1))
git_list() {
eval "git ls-tree $RECURSIVE --name-only HEAD" | while read -r filename; do
echo "$(git log -1 --format="%ad" -- "$filename")"$'\t'"$filename"
done
}
git_list |
sort -t' ' -k5,5n -k2,2M -k3,3n -k4,4n |
column -ts$'\t'