revisit command last - notes - a console notes manager using git | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 71f0cbd9e967d15c0881e69447d0ceded20a0142 | |
parent a9b16c50298a1b736f8b17e440ef432c9099514e | |
Author: Solene Rapenne <[email protected]> | |
Date: Tue, 7 May 2019 12:32:50 +0200 | |
revisit command last | |
Diffstat: | |
M notes | 41 ++++++++++++++++++++---------… | |
1 file changed, 26 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/notes b/notes | |
@@ -113,23 +113,34 @@ delete() { | |
# display the list of edited files ordered by time | |
last() { | |
cd "$REPO" | |
- git log --pretty="%cr" --name-only | \ | |
- awk -v limit="$1" '{ | |
- date=$0 ; | |
- getline; getline; | |
- file=$0 ; | |
- seen[file]++; | |
- if(seen[file]==1) { | |
- if(limit != "") { | |
- output++; | |
- if(output <= limit) { | |
- printf("%20s: %s\n", date, f… | |
- } | |
- } else { | |
- printf("%20s: %s\n", date, file) | |
+ git log --name-only | \ | |
+ awk ' | |
+ /^commit / { | |
+ date="no" | |
+ next | |
+ } | |
+ | |
+ /^Date/ { | |
+ date=substr($0,index($0,$2)) | |
+ getline | |
+ for(s="x";s!="";) { | |
+ getline | |
+ s=$0 | |
+ } | |
+ next | |
+ } | |
+ | |
+ { | |
+ if(date!="no" && | |
+ substr($0,0,1)!=" " && | |
+ length($0)>1) | |
+ { | |
+ seen[$0]++ | |
+ if(seen[$0]==1) { | |
+ print date"\t"$0 | |
} | |
} | |
- }' | |
+ }' | head -n $1 | |
exit 0 | |
} | |