logo

utils

~/.local/bin tools and git-hooks
commit: 8093f17084f8a8c94a7382f451147a4cb4dbd090
parent: 941228360a270bc142341d64ab5d991c17a72221
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 22 Mar 2017 23:26:59 +0100

Moved files, sorry too lazy for real commits

Diffstat:

Dargc.c4----
Abin/cron-portage.sh7+++++++
Abin/timey-whyme.sh41+++++++++++++++++++++++++++++++++++++++++
Dbuild.sh3---
Adoc/README2++
Amake.sh47+++++++++++++++++++++++++++++++++++++++++++++++
Drange.c34----------------------------------
Asrc/argc.c6++++++
Asrc/range.c36++++++++++++++++++++++++++++++++++++
Dtimey-whyme.sh39---------------------------------------
10 files changed, 139 insertions(+), 80 deletions(-)

diff --git a/argc.c b/argc.c @@ -1,4 +0,0 @@ -#include <stdio.h> -int main(int argc, char *argv[]) { - printf("%s: %i\n", argv[0], argc); -} diff --git a/bin/cron-portage.sh b/bin/cron-portage.sh @@ -0,0 +1,7 @@ +#!/bin/sh +export PS4='>> ' ; set -x +emerge -q --sync +for i in "@security" "@world" "@preserved-rebuild"; do emerge -1uvDNq --with-bdeps=y --keep-going --verbose-conflicts $i; done +emerge -catv +eclean -d distfiles +eclean packages diff --git a/bin/timey-whyme.sh b/bin/timey-whyme.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Copyright CC-BY-SA-4.0 2017- Haelwenn (lanodan) Monnier <contact@hacktivis.me> + +xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" +today=$(date --date=${2:-now} +%Y-%m-%d) +later=$(date --date=${2:-+7days} +%Y-%m-%d) +heading='\t%s\n' +highlight='%s' +form='column -s, -o  -t' + +usage() { + printf "Usage: [[all|both|cal|todo] [date]]\n" +} + +todo() { + printf $heading 'To Do List' + printf $highlight $(grep "^$today" $xdd/todo.csv | $form) + grep -E -v "^(#|$today)" $xdd/todo.csv | $form +} + +calendar() { + echo "1970-01-01,###, Calendar, ### +${today},###, Now +7 days, ### +${later},###, Later,### +$(grep -v '^#' $xdd/calendar.csv)" | sort | $form +} + +case "$1" in + all*|both*|"") + todo; calendar + ;; + todo*) + todo + ;; + cal*) + calendar + ;; + *) + usage + ;; +esac diff --git a/build.sh b/build.sh @@ -1,3 +0,0 @@ -#!/bin/sh -set -x -for i in *.c; do ${CC:-cc} $i ${CFLAGS:--Wall} -o ${i%.c}; done diff --git a/doc/README b/doc/README @@ -0,0 +1 @@ +../README+ \ No newline at end of file diff --git a/make.sh b/make.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Copyright CC-BY-SA-4.0 2017- Haelwenn (lanodan) Monnier <contact@hacktivis.me> + +CC=${CC:-cc} +CFLAGS=${CFLAGS:--Wall} +PREFIX=${PREFIX:-/usr/local} +BINDIR=${BINDIR:-${PREFIX}/bin} +LIBDIR=${LIBDIR:-${PREFIX}/lib} +DOCDIR=${DOCDIR:-${PREFIX}/share/doc/lanodan-utils} + +usage() { + echo "$0: [all|install] +install uses PREFIX, LIBDIR, BINDIR, DOCDIR, environment variables" +} + +all() { + for i in src/*.c; do + ${CC} ${CFLAGS} $i -o $(sed -r 's/src(.*).c/bin\1/'<<<$i) + done +} + +install() { + mkdir -p ${BINDIR} && cp bin/* ${BINDIR}; + mkdir -p ${DOCDIR} && cp doc/* ${DOCDIR}; + mkdir -p ${LIBDIR} && cp lib/* ${LIBDIR}; +} + +clean() { + rm -fr bin/* +} + +set -x + +case "$1" in + all*|"") + all + ;; + inst*) + install + ;; + clean*) + clean + ;; + *) + usage + ;; +esac diff --git a/range.c b/range.c @@ -1,34 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -char *IFS; -int a, b; - -void usage(char *a0) { - printf("usage: %s [ini <max>]\n", a0); -} - -void range(int initial, int maximum) { - printf("%i", initial); - if(initial<maximum) { - for(initial++; initial<=maximum; initial++) - printf("%s%i", IFS, initial); - } else if(initial>maximum) { - for(initial--; initial>=maximum; initial--) - printf("%s%i", IFS, initial); - } -} - -int main(int argc, char *argv[]){ - if(!(IFS = getenv("IFS"))) { - IFS = " "; - } - - if (argc == 2) { - range(0, atoi(argv[1])); - } else if(argc == 3) { - range(atoi(argv[1]), atoi(argv[2])); - } else { - usage(argv[0]); - } -} diff --git a/src/argc.c b/src/argc.c @@ -0,0 +1,6 @@ +// Copyright CC-BY-SA-4.0 2017- Haelwenn (lanodan) Monnier <contact@hacktivis.me> + +#include <stdio.h> +int main(int argc, char *argv[]) { + printf("%s: %i\n", argv[0], argc); +} diff --git a/src/range.c b/src/range.c @@ -0,0 +1,36 @@ +// Copyright CC-BY-SA-4.0 2017- Haelwenn (lanodan) Monnier <contact@hacktivis.me> + +#include <stdio.h> +#include <stdlib.h> + +char *IFS; +int a, b; + +void usage(char *a0) { + printf("usage: %s [ini <max>]\n", a0); +} + +void range(int initial, int maximum) { + printf("%i", initial); + if(initial<maximum) { + for(initial++; initial<=maximum; initial++) + printf("%s%i", IFS, initial); + } else if(initial>maximum) { + for(initial--; initial>=maximum; initial--) + printf("%s%i", IFS, initial); + } +} + +int main(int argc, char *argv[]){ + if(!(IFS = getenv("IFS"))) { + IFS = " "; + } + + if (argc == 2) { + range(0, atoi(argv[1])); + } else if(argc == 3) { + range(atoi(argv[1]), atoi(argv[2])); + } else { + usage(argv[0]); + } +} diff --git a/timey-whyme.sh b/timey-whyme.sh @@ -1,39 +0,0 @@ -#!/bin/sh - -xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" -today=$(date +%Y-%m-%d) -heading='\t%s\n' -highlight='%s' -form="column -s, -t -o " - -usage() { - printf "Usage:\n" - printf "$0 calendar <year> <month> <day>\n" - printf "\t output calendar for given time\n" - printf "$0 todo <year> <month> <day>\n" - printf "\t output todo for given time\n" -} - -todo() { - printf $heading 'To Do List' - printf $highlight $(grep "^$today" $xdd/todo.csv | $form) - grep -E -v "^(#|$today)" $xdd/todo.csv | $form -} - -calendar() { - printf $heading 'Calendar' - printf $highlight $(grep "(^$today|;$today)" $xdd/calendar.csv | $form) - grep -E -v "^(#|;?$today)" $xdd/calendar.csv | $form -} - -case "$1" in - todo*) - todo - ;; - cal*) - calendar - ;; - *) - usage - ;; -esac