aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-20 15:47:10 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-20 15:47:10 +0100
commit428d6e34e529046e0272db77908114e1b1809202 (patch)
tree9f18a20d4248e7fa103062d89a1f1079da2c3d8b
parentfb40bc617913ab7b357f4acd30e58dad399d366e (diff)
downloadalpine-428d6e34e529046e0272db77908114e1b1809202.tar.gz
Truncate apk-file output in tty
-rwxr-xr-xapk-file7
1 files changed, 5 insertions, 2 deletions
diff --git a/apk-file b/apk-file
index 912d86a..f5abc5f 100755
--- a/apk-file
+++ b/apk-file
@@ -2,11 +2,14 @@
# Search packages by contents
-curl -s "https://pkgs.alpinelinux.org/contents?file=$1" |
+COLUMNS=`resize | cut -d\; -f1 | cut -d= -f2`
+
+curl -s "https://pkgs.alpinelinux.org/contents?file=$1&arch=${2:-x86}" |
awk '
/<td>/ { print }
/<td class="(arch|repo)">/ { getline; getline; print }
' |
sed 's/^ *//; s/<[^>]*>//g; s,&#x2F;,/,g' |
paste - - - - - |
-grep "${2:-x86}\$"
+column -to ' ' |
+{ test -t 1 && cut -c -$COLUMNS || cat; }