blob: c68cc5140db594e7bf3581c085075b0b9c80010b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/sh
# 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 -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
|