Add conditional ellipses to lh
dblume

dblume commited on 2024-01-18 08:34:21
Showing 1 changed files, with 6 additions and 1 deletions.

... ...
@@ -149,8 +149,13 @@ esac
149 149
 alias clip="expand | cut -b1-\$COLUMNS"
150 150
 
151 151
 # I'm often interested in just the most recently changed file
152
+# N.B. If changing -l to -1, remove tail, because "total" line is only for -l
152 153
 lh() {
153
-    ls --color=always -ltq "$@" | head -$(($LINES/3)) | tail --lines=+2
154
+#    ls --color=always -1tqh "$@" | head -$(($LINES/3))
155
+    ls --color=always -ltqh "$@" | head -$(($LINES/3)) | tail --lines=+2
156
+    if [ $(ls -1 | wc -l) -gt $(($LINES/3)) ]; then
157
+        echo ...
158
+    fi
154 159
 }
155 160
 
156 161
 # For httpie: https://github.com/jakubroztocil/httpie#installation
157 162