summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2026-01-01 13:07:53 -0800
committerThomas Ulmer <thomasmulmer02@gmail.com>2026-01-01 13:07:53 -0800
commit76684c322a609f7ca31d86c9ffd0f318ef45e3c7 (patch)
treefbca3cde4d8b20d39d87f1f0307904727f5c714d /misc
parent1ddfd22747b7ea304d7e58877b484ff49485f2f8 (diff)
misc: new subdir + move lk
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/lk.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/misc/lk.sh b/misc/lk.sh
new file mode 100755
index 0000000..5f760c6
--- /dev/null
+++ b/misc/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=always -Alh"
+
+if [ $# -lt 1 ]; then
+ # take stdin instead
+ $dirView $(pwd) | ${longView}
+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