Add a limit to last command - notes - a console notes manager using git | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit d653696ab341e4b8c43e55ef15198b70a6c5f26b | |
parent a17b04a52738103de48395d28fef14ec06008b64 | |
Author: Solene Rapenne <[email protected]> | |
Date: Mon, 16 Jul 2018 11:42:32 +0200 | |
Add a limit to last command | |
Diffstat: | |
M notes | 17 ++++++++++++----- | |
M notes.1 | 8 ++++++-- | |
2 files changed, 18 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/notes b/notes | |
@@ -25,7 +25,7 @@ usage() { | |
': show hierarchy tree' \ | |
"$name init" \ | |
': initialize the git repository' \ | |
- "$name last" \ | |
+ "$name last [limit]" \ | |
': show files ordered by edition time' \ | |
"$name history PATH" \ | |
': uses tig to display file history' \ | |
@@ -114,13 +114,20 @@ delete() { | |
last() { | |
cd "$REPO" | |
git log --pretty="%cr" --name-only | \ | |
- awk '{ | |
+ awk -v limit="$1" '{ | |
date=$0 ; | |
getline; getline; | |
file=$0 ; | |
seen[file]++; | |
if(seen[file]==1) { | |
- printf("%20s: %s\n", date, file) | |
+ if(limit != "") { | |
+ output++; | |
+ if(output < limit) { | |
+ printf("%20s: %s\n", date, f… | |
+ } | |
+ } else { | |
+ printf("%20s: %s\n", date, file) | |
+ } | |
} | |
}' | |
exit 0 | |
@@ -161,8 +168,8 @@ fi | |
case "$1" in | |
'') display ;; | |
ls) display ;; | |
- i*) initialization ;; | |
- la*) last ;; | |
+ init) initialization ;; | |
+ last) last "$2" ;; | |
e*) [ -n "$2" ] && edit "$2" ;; | |
hi*) [ -n "$2" ] && histo "$2" ;; | |
r*) [ -n "$2" ] && delete "$2" ;; | |
diff --git a/notes.1 b/notes.1 | |
@@ -61,8 +61,12 @@ Execute | |
on | |
.Ar file | |
to display commit history. | |
-.It Nm Cm last | |
-display files and their last commit time ordered by time. | |
+.It Nm Cm last Op limit | |
+display files and their last commit time ordered by time. If | |
+.Ar limit | |
+is passed, only | |
+.Ar limit | |
+lines are displayed. | |
This is useful to find which files have been modified lastly. | |
.It Nm Cm init |