iomenu

interactive terminal dmenu-style menu
Log | Files | Refs | README | LICENSE

commit cee77319ba6cc232295cf29688ba6eb3c58be246
parent f4ee636cedac29de2e5f6ff200f01db97379642c
Author: Josuah Demangeon <me@josuah.net>
Date:   Sat,  9 May 2020 20:57:56 +0200

improve scripts portability and correctness

Diffstat:
Abin/column-t | 21+++++++++++++++++++++
Mbin/io-fstab | 10+++++-----
Mbin/io-man | 2+-
Mbin/io-net | 2+-
Mbin/io-passwd | 4++--
Mbin/io-xdg-open | 2++
6 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/bin/column-t b/bin/column-t @@ -0,0 +1,21 @@ +#!/usr/bin/awk -f +# format text in aligned two-space separated columns: portable column -t + +{ + for (f = 1; f <= NF; f++) { + l = length($f) + if (l > len[f]) + len[f] = l + field[NR"|"f] = $f + } + if (--f > count) + count = f +} + +END { + for (row = 1; row <= NR; row++) { + for (f = 1; f < count; f++) + printf("%-"len[f]"s ", field[row"|"f]) + printf("%s\n", field[row"|"f]) + } +} diff --git a/bin/io-fstab b/bin/io-fstab @@ -2,8 +2,8 @@ # display mounts and fstab in iomenu { - printf '#/etc/fstab\n' - column -ts ' ' </etc/fstab - printf '#mount\n' - mount | column -ts ' ' -} | iomenu -# + echo "#/etc/fstab" + column-t -F '[ \t]' /etc/fstab + echo "#mount" + mount | column-t -F '[ \t]' +} | exec iomenu -# diff --git a/bin/io-man b/bin/io-man @@ -4,4 +4,4 @@ man -k ' ' | sed -r ' s/ - / - / s/(.{25}[^ ]* ) * - /\1- / -' | iomenu | sed -r 's,[(,].*,,' | xargs man +' | iomenu | sed -r 's,[(,].*,,' | tr '\n' '\0' | xargs -0r man diff --git a/bin/io-net b/bin/io-net @@ -1,4 +1,4 @@ #!/bin/sh -e # searchable netstat results with iomenu -netstat "$@" | sed 's/^[AP]/#&/' | iomenu -'#' +netstat -n "$@" | sed 's/^[AP]/#&/' | iomenu -'#' diff --git a/bin/io-passwd b/bin/io-passwd @@ -3,7 +3,7 @@ { printf '#/etc/passwd\n' - column -ts : < /etc/passwd + column-t -F : < /etc/passwd printf '#/etc/group\n' - column -ts : < /etc/group + column-t -F : < /etc/group } | iomenu -'#' diff --git a/bin/io-xdg-open b/bin/io-xdg-open @@ -5,6 +5,8 @@ LC_COLLATE=C +touch "$HOME/.cache/find" + if test -f "$HOME/.cache/find" && test $# = 0 then exec "$0" "$HOME" elif test $# = 0