last command to display edited files ordered by time - notes - a console notes manager using git DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit e5b96dbf99c8250f3b5287f5c0d75dd65640edd3 DIR parent ce023c3de7b4912fd987ab660606a8a67a88c47d HTML Author: Solene Rapenne <solene@perso.pw> Date: Fri, 13 Jul 2018 18:29:41 +0200 last command to display edited files ordered by time Diffstat: M notes | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+), 0 deletions(-) --- DIR diff --git a/notes b/notes @@ -86,6 +86,22 @@ delete() { fi } +# display the list of edited files ordered by time +last() { + DEST="$1" + cd "$REPO" + git log --pretty="%cr" --name-only | \ + awk '{ + date=$0 ; + getline; getline; + file=$0 ; + seen[file]++; + if(seen[file]==1) { + printf("%20s: %s\n", date, file) + } + }' +} + # create a git repo initialization() { cd $REPO @@ -116,5 +132,9 @@ if expr "$PARAM1" : "^hi" >/dev/null && [ -n "$PARAM2" ]; then histo "$PARAM2" ; if expr "$PARAM1" : "^c" >/dev/null && [ -n "$PARAM2" ]; then show_file "$PARAM2" ; exit 0 ; fi if [ "$PARAM1" = "rm" ] && [ -n "$PARAM2" ]; then delete "$PARAM2" ; exit 0 ; fi if expr "$PARAM1" : "^he" >/dev/null ; then usage ; exit 0 ; fi +if expr "$PARAM1" : "^l" >/dev/null ; then last; exit 0 ; fi +if [ -f "${REPO}/${PARAM1}" ] ; then edit "$PARAM1" ; exit 0 ; fi +# nothing matched +echo "${PARAM1} is not a valid command or an existing filename" && exit 5