summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2025-12-29 15:02:35 -0800
committerThomas Ulmer <thomasmulmer02@gmail.com>2025-12-29 15:02:35 -0800
commit1ddfd22747b7ea304d7e58877b484ff49485f2f8 (patch)
tree7b3bb71e304945991a2aae890901ad16cc9d946f
parentc377f38c23594c7a8a2813a412ef5e49755762e5 (diff)
util: small ls+pager util
-rwxr-xr-xlk.sh28
-rw-r--r--symlinks.csv1
2 files changed, 29 insertions, 0 deletions
diff --git a/lk.sh b/lk.sh
new file mode 100755
index 0000000..967332a
--- /dev/null
+++ b/lk.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# This is helper that should replace a number of common commands
+#
+# It is intended to be named `lk`, short for "look"
+
+longView=${PAGER:-$(which less || which more || echo "cat")}
+dirView="ls --color=auto -Alh"
+
+if [ $# -lt 1 ]; then
+ # take stdin instead
+ $dirView $(pwd)
+fi
+
+for a in $@; do
+ if [ $a == "" ]; then
+ echo "Empty argument skipped"
+ elif [ ! -e $a ]; then
+ echo "$a does not exist" 1>&2
+ exit -1
+ elif [ -d $a ]; then
+ $dirView $a
+ elif [ $(tput lines) -ge $(($(wc -l < $a) - 2)) ]; then
+ cat $a
+ else
+ ${longView} $a
+ fi
+done
diff --git a/symlinks.csv b/symlinks.csv
index 6589763..241c411 100644
--- a/symlinks.csv
+++ b/symlinks.csv
@@ -14,3 +14,4 @@ brightness/brightnessmax,.local/bin/brightnessmax
volume/volumeup,.local/bin/volumeup
volume/volumedown,.local/bin/volumedown
volume/volumemute,.local/bin/volumemute
+lk.sh,.local/bin/lk