From 9139a1b136fa2b5adfcac0ac09a4f61aa1ee1ff4 Mon Sep 17 00:00:00 2001 From: Thomas Ulmer Date: Wed, 4 Feb 2026 14:24:16 -0800 Subject: full reorg --- scripts/misc/lk.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 scripts/misc/lk.sh (limited to 'scripts/misc') diff --git a/scripts/misc/lk.sh b/scripts/misc/lk.sh new file mode 100755 index 0000000..5f760c6 --- /dev/null +++ b/scripts/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 -- cgit v1.2.3