logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 96ffc7b190977be4ef23bc8fa6ef3bc0dbf0fef9
parent a69c18fd8c0d31ea4a392f680a89252a69de1173
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 15 May 2022 16:49:22 +0200

Split binaries and scripts

Goal is to allow plan9-style multi-arch on executables.

Diffstat:

MMakefile11+++++++++--
Mbin/Makefile6------
Dbin/timey-whyme.sh105-------------------------------------------------------------------------------
Mconfigure14++++++++++----
Rbin/zalgo -> perl/zalgo0
Rbin/archive-tags -> sh/archive-tags0
Rbin/cron-portage.sh -> sh/cron-portage.sh0
Rbin/dmenu_path -> sh/dmenu_path0
Rbin/stagit-new -> sh/stagit-new0
Ash/timey-whyme.sh105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rbin/wordsort -> sh/wordsort0
Rbin/xbel-menu -> sh/xbel-menu0
12 files changed, 124 insertions(+), 117 deletions(-)

diff --git a/Makefile b/Makefile @@ -10,7 +10,7 @@ test: all .PHONY: lint lint: - $(SHELLCHECK) ./configure test_all.sh test_functions.sh + $(SHELLCHECK) ./configure test_all.sh test_functions.sh ./sh/* SHELLCHECK=${SHELLCHECK} ./test-bin/shellcheck ${FLAWFINDER} --error-level=4 . cd bin ; $(MAKE) lint @@ -20,7 +20,14 @@ clean: cd bin ; $(MAKE) clean cd sbin ; $(MAKE) clean -install: +install: script-install bin-install + +script-install: + mkdir -p $(DESTDIR)$(SHELLDIR)/ $(DESTDIR)$(PERLDIR)/ + cp -r sh/* $(DESTDIR)$(SHELLDIR)/ + cp -r perl/* $(DESTDIR)$(PERLDIR)/ + +bin-install: cd bin ; $(MAKE) install cd sbin ; $(MAKE) install diff --git a/bin/Makefile b/bin/Makefile @@ -2,14 +2,9 @@ include config.mk include ../config.mk include ../Makefile.common -SH_SCRIPTS = archive-tags dmenu_path wordsort -PL_SCRIPTS = zalgo -SCRIPTS = $(SH_SCRIPTS) $(PL_SCRIPTS) - .PHONY: lint lint: $(MANDOC) -Tlint -Wunsupp,error,warning $(MAN1) - $(SHELLCHECK) $(SH_SCRIPTS) lolcat: lolcat.c Makefile rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno} @@ -31,6 +26,5 @@ strings: strings.c Makefile install: mkdir -p ${DESTDIR}${BINDIR}/ cp -p ${EXE} ${DESTDIR}${BINDIR}/ - cp -p ${SCRIPTS} ${DESTDIR}${BINDIR}/ mkdir -p ${DESTDIR}${MANDIR}/man1 cp -p ${MAN1} ${DESTDIR}${MANDIR}/man1 diff --git a/bin/timey-whyme.sh b/bin/timey-whyme.sh @@ -1,105 +0,0 @@ -#!/bin/sh -# Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> -# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only -xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" -today="$(date --date=now +%Y-%m-%d)" -later="$(date --date=+7days +%Y-%m-%d)" -headers=true - -usage() { - echo "$0"' [t…|c…|h…] - c…: show calendar - t…: show todo - h…: this help' - - echo ' -Files used: - • '"$xdd"'/calendar.csv - • '"$xdd"'/todo.csv' - - echo ' -Environment used: - XDG_DATA_DIR (defaults to “~/.local/share”)' -} - -die() { - echo "$1" - exit -} - -verify_xxd() { - [ -e "${xdd}/${1}" ] || die "Please create the following file, see examples for help: ${xdd}/${1}" -} - -todo_gen() { -# (GNU-ism) nowarn: turn off warning: table wider than line width - echo \ -'.color 1 -.TS -nowarn; -llll.' - $headers && echo \ -'.TH -Deadline Nice Description Location -.TB -_' - ( - cut -d '#' -f -1 "$xdd/todo.csv" | grep -v '^$' - echo "${today},\m[blue],Now" - echo "${later},\m[],In 7 days" - ) | sort -n | tr ',' ' ' - echo '.TE' -} - -calendar_gen() { -# (GNU-ism) nowarn: turn off warning: table wider than line width - echo \ -'.color 1 -.TS -nowarn; -llll.' - $headers && echo \ -'.TH -Start End Description Location -.TB -_' - ( - cut -d '#' -f -1 "$xdd/calendar.csv" | grep -v '^$' - echo "${today},\m[blue],Now" - echo "${later},\m[],In 7 days" - ) | sort -n | tr ',' ' ' - echo '.TE' -} - -calendar() { - verify_xxd calendar.csv - # -t : preprocess with tbl(1) - # grep -v '^$' : remove empty lines - calendar_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' -} -todo() { - verify_xxd todo.csv - todo_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' -} - -if [[ "$1" == "-h" ]]; then - headers=false - shift -fi - -case "$1" in - c*) - calendar - ;; - t*) - todo - ;; - h*) - usage - ;; - *) - todo - echo - calendar - ;; -esac diff --git a/configure b/configure @@ -9,6 +9,8 @@ Usage: [variables] configure [variables] Variables: PREFIX=DIR BINDIR=DIR + SHELLDIR=DIR + PERLDIR=DIR SBINDIR=DIR MANDIR=DIR @@ -117,6 +119,8 @@ done # Fallback definitions for dirs, based on $PREFIX BINDIR="${BINDIR:-${PREFIX}/bin}" +SHELLDIR="${SHELLDIR:-${BINDIR}}" +PERLDIR="${PERLDIR:-${BINDIR}}" SBINDIR="${SBINDIR:-${PREFIX}/sbin}" MANDIR="${MANDIR:-${PREFIX}/share/man}" @@ -205,10 +209,12 @@ printf 'Writing sbin/config.mk ...' printf 'Writing to config.mk ...' cat >config.mk <<EOF # Autogenerated by ./configure -PREFIX = ${PREFIX} -BINDIR = ${BINDIR} -SBINDIR = ${SBINDIR} -MANDIR = ${MANDIR} +PREFIX = ${PREFIX} +BINDIR = ${BINDIR} +SHELLDIR = ${SHELLDIR} +PERLDIR = ${PERLDIR} +SBINDIR = ${SBINDIR} +MANDIR = ${MANDIR} PKGCONFIG = ${PKGCONFIG} CC = ${CC} diff --git a/bin/zalgo b/perl/zalgo diff --git a/bin/archive-tags b/sh/archive-tags diff --git a/bin/cron-portage.sh b/sh/cron-portage.sh diff --git a/bin/dmenu_path b/sh/dmenu_path diff --git a/bin/stagit-new b/sh/stagit-new diff --git a/sh/timey-whyme.sh b/sh/timey-whyme.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# Copyright 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only +xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" +today="$(date --date=now +%Y-%m-%d)" +later="$(date --date=+7days +%Y-%m-%d)" +headers=true + +usage() { + echo "$0"' [t…|c…|h…] + c…: show calendar + t…: show todo + h…: this help' + + echo ' +Files used: + • '"$xdd"'/calendar.csv + • '"$xdd"'/todo.csv' + + echo ' +Environment used: + XDG_DATA_DIR (defaults to “~/.local/share”)' +} + +die() { + echo "$1" + exit +} + +verify_xxd() { + [ -e "${xdd}/${1}" ] || die "Please create the following file, see examples for help: ${xdd}/${1}" +} + +todo_gen() { +# (GNU-ism) nowarn: turn off warning: table wider than line width + echo \ +'.color 1 +.TS +nowarn; +llll.' + $headers && echo \ +'.TH +Deadline Nice Description Location +.TB +_' + ( + cut -d '#' -f -1 "$xdd/todo.csv" | grep -v '^$' + echo "${today},\m[blue],Now" + echo "${later},\m[],In 7 days" + ) | sort -n | tr ',' ' ' + echo '.TE' +} + +calendar_gen() { +# (GNU-ism) nowarn: turn off warning: table wider than line width + echo \ +'.color 1 +.TS +nowarn; +llll.' + $headers && echo \ +'.TH +Start End Description Location +.TB +_' + ( + cut -d '#' -f -1 "$xdd/calendar.csv" | grep -v '^$' + echo "${today},\m[blue],Now" + echo "${later},\m[],In 7 days" + ) | sort -n | tr ',' ' ' + echo '.TE' +} + +calendar() { + verify_xxd calendar.csv + # -t : preprocess with tbl(1) + # grep -v '^$' : remove empty lines + calendar_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' +} +todo() { + verify_xxd todo.csv + todo_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' +} + +if [ "$1" = "-h" ]; then + headers=false + shift +fi + +case "$1" in + c*) + calendar + ;; + t*) + todo + ;; + h*) + usage + ;; + *) + todo + echo + calendar + ;; +esac diff --git a/bin/wordsort b/sh/wordsort diff --git a/bin/xbel-menu b/sh/xbel-menu