git: Add last-changed to mimic github file browser

List all files and directories but include the latest commits date and
subject, similar to the file browser in web-UIs of services like GitHub.
Also sort the entries by the commits date and time to see the most
recent changed files/folders at the bottom.
This commit is contained in:
2023-01-17 01:38:17 +01:00
parent a7b975ae71
commit f317ed81c2
2 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env zsh
#
# List all files and directories but include the latest commits date and
# subject, similar to the file browser in web-UIs of services like GitHub. Also
# sort the entries by the commits date and time to see the most recent changed
# files/folders at the bottom.
ls -1 "$@" \
| while read -r line; do
git_info="$(git log -1 --format=$'%ci\t%s' "$line")"
printf "%s\t%s\n" "$line" "$git_info"
done \
| sort -r -t$'\t' -k2,2 \
| column -s$'\t' -t \
| cut -c -"$COLUMNS"