about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-08-26 22:49:35 +0200
committerLeah Neukirchen <leah@vuxu.org>2022-08-26 22:49:35 +0200
commit01ceb9c89ddeffbb45f14b68a26b45734f7cf5b2 (patch)
tree3ba993c0b6633d75d96518b09483921f54b9d2c4
parentca309754c6aba81be4f290279666a68f75306d70 (diff)
downloadlr-01ceb9c89ddeffbb45f14b68a26b45734f7cf5b2.tar.gz
lr-01ceb9c89ddeffbb45f14b68a26b45734f7cf5b2.tar.xz
lr-01ceb9c89ddeffbb45f14b68a26b45734f7cf5b2.zip
add -of to sort by file basename.
Closes #21.
-rw-r--r--README.md1
-rw-r--r--lr.14
-rw-r--r--lr.c2
3 files changed, 6 insertions, 1 deletions
diff --git a/README.md b/README.md
index b82e25e..9cae222 100644
--- a/README.md
+++ b/README.md
@@ -128,6 +128,7 @@ Default: `n`.
 * `c`: ctime.
 * `d`: path depth.
 * `e`: file extension.
+* `f`: file basename.
 * `i`: inode number.
 * `m`: mtime.
 * `n`: file name.
diff --git a/lr.1 b/lr.1
index 5082a8e..002bf87 100644
--- a/lr.1
+++ b/lr.1
@@ -1,4 +1,4 @@
-.Dd December 5, 2019
+.Dd August 26, 2022
 .Dt LR 1
 .Os
 .Sh NAME
@@ -322,6 +322,8 @@ ctime
 path depth
 .It Ic e
 file extension
+.It Ic f
+file basename
 .It Ic i
 inode number
 .It Ic m
diff --git a/lr.c b/lr.c
index b523265..95cc098 100644
--- a/lr.c
+++ b/lr.c
@@ -1459,6 +1459,8 @@ order(const void *a, const void *b)
 		              "ZZZZAZZZZZZZZZZZ"[(fa->sb.st_mode >> 12) & 0x0f]);
 		case 'n': STRCMP(fa->fpath, fb->fpath);
 		case 'N': STRCMP(fb->fpath, fa->fpath);
+		case 'f': STRCMP(basenam(fa->fpath), basenam(fb->fpath));
+		case 'F': STRCMP(basenam(fb->fpath), basenam(fa->fpath));
 		case 'e': STRCMP(extnam(fa->fpath), extnam(fb->fpath));
 		case 'E': STRCMP(extnam(fb->fpath), extnam(fa->fpath));
 		case 'p': DIRCMP(fa->fpath, fb->fpath);