scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

commit a75c732b88bd27e351368b1a7b0c111df5488be1
parent 500da620557e19c334882e50ffbd92d6e53a4b76
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Thu, 11 Jul 2024 11:49:38 +0200

Merge branch 'master' of tronto.net:scripts

Diffstat:
Malg | 126++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mconfig-backup | 17+++++++++++++----
Mfeed | 5+----
3 files changed, 136 insertions(+), 12 deletions(-)

diff --git a/alg b/alg @@ -6,7 +6,10 @@ # Example: alg c UBL E - prints out all first algs for UBL-FDR-* usage() { - echo "Usage: alg [[edit] (c|e|w|x) [buffer] (1 letter|2 letters)]" + echo "Usage:" + echo "alg" + echo "alg edit (c|e|w|x) [buffer] (1 letter|2 letters)" + echo "alg export (c|e|w|x|all)" } default_editor=vi @@ -178,13 +181,128 @@ showall_x() { done } +export_csv_c() { + sorted_letters="d b c l n p m k z f j v w g a o e s r u t" + buffer="$cbuffer" + f="$basedir/corners/$buffer" + printf '"",' + for first in $sorted_letters; do + printf '"%s",' "$(corner $first)" + done + printf '\n' + for first in $sorted_letters; do + firstpiece="$(corner $first)" + printf '"%s",' "$firstpiece" + for second in $sorted_letters; do + g="$f/$firstpiece/$(corner $second)" + if [ "$first" = "$second" ] || [ ! -f "$g" ]; then + printf '"",' + else + printf '"%s",' "$(head -n 1 "$g")" + fi + done + printf '\n' + done +} + +export_csv_e() { + sorted_letters="d c b n l p m k z f v j w g i a o e t r u s" + buffer="$ebuffer" + f="$basedir/edges/$buffer" + printf '"",' + for first in $sorted_letters; do + printf '"%s",' "$(edge $first)" + done + printf '\n' + for first in $sorted_letters; do + firstpiece="$(edge $first)" + printf '"%s",' "$firstpiece" + for second in $sorted_letters; do + g="$f/$firstpiece/$(edge $second)" + if [ "$first" = "$second" ] || [ ! -f "$g" ]; then + printf '"",' + else + printf '"%s",' "$(head -n 1 "$g")" + fi + done + printf '\n' + done +} + +export_csv_w() { + sorted_letters="b d c n l p m k x z f v j w g i a o e t r u s" + buffer="$wbuffer" + f="$basedir/wings/$buffer" + printf '"",' + for first in $sorted_letters; do + printf '"%s",' "$(wing $first)" + done + printf '\n' + for first in $sorted_letters; do + firstpiece="$(wing $first)" + printf '"%s",' "$firstpiece" + for second in $sorted_letters; do + g="$f/$firstpiece/$(wing $second)" + if [ "$first" = "$second" ] || [ ! -f "$g" ]; then + printf '"",' + else + printf '"%s",' "$(head -n 1 "$g")" + fi + done + printf '\n' + done +} + +export_csv_x() { + sorted_letters="d c b l n p m k x z f j v w g i a o e s r u t" + buffer="$xbuffer" + f="$basedir/xcenters/$buffer" + printf '"",' + for first in $sorted_letters; do + printf '"%s",' "$(xcenter $first)" + done + printf '\n' + for first in $sorted_letters; do + firstpiece="$(xcenter $first)" + printf '"%s",' "$firstpiece" + for second in $sorted_letters; do + g="$f/$firstpiece/$(xcenter $second)" + if [ "$first" = "$second" ] || [ ! -f "$g" ]; then + printf '"",' + else + printf '"%s",' "$(head -n 1 "$g")" + fi + done + printf '\n' + done +} + run() { - if [ "$1" = "edit" ]; then + case "$1" in + edit) editor="$default_editor" shift - else + ;; + export) + if [ "$2" = "all" ]; then + mkdir -p bldsheets + export_csv_c > bldsheets/corners.csv + export_csv_e > bldsheets/edges.csv + export_csv_w > bldsheets/wings.csv + export_csv_x > bldsheets/xcenters.csv + echo "Sheets exported to bldsheets" + return + fi + #TODO add option for alternative buffers + [ "$2" != "c" ] && [ "$2" != "e" ] && \ + [ "$2" != "w" ] && [ "$2" != "x" ] && usage && return + export_csv_$2 + return + ;; + *) editor="cat" - fi + ;; + esac type="$1" if [ -z "$3" ]; then diff --git a/config-backup b/config-backup @@ -6,15 +6,24 @@ folder=$HOME/box/configbackups dotfiles=".bash_profile .bashrc .profile .inputrc .mblaze .nexrc .tmux.conf .xinitrc" config="colors fontconfig git imv msmtp zathura" -src="dmenu dwm st st-lightbg" +src="dmenu dwm st" for d in config home src ssh; do mkdir -p "$folder/$d"; done # copy -for i in $dotfiles; do cp -Rf "$HOME"/"$i" "$folder"/home/; done -for i in $config; do cp -Rf "$HOME"/.config/"$i" "$folder"/config/; done -for i in $src; do cp -Rf "$HOME"/.local/src/"$i" "$folder"/src/; done +for i in $dotfiles; + do cp -Rf "$HOME"/"$i" "$folder"/home/ +done + +for i in $config + do cp -Rf "$HOME"/.config/"$i" "$folder"/config/ +done + +for i in $src + do mkdir "$folder"/src/"$i" + cp -f "$HOME"/.local/src/"$i"/*.{c,h} "$folder"/src/"$i"/ +done cp "$HOME"/.ssh/config "$folder"/ssh/ diff --git a/feed b/feed @@ -9,7 +9,6 @@ dir=$HOME/box/sfeed feeddir=$dir/urls destdir=$dir/new -olddir=$dir/old readdir=$dir/last menu="dmenu -l 20 -i" urlopener=open-url @@ -82,9 +81,7 @@ case "$1" in show | selectmenu ;; clear) - d="$olddir/$(date +'%Y-%m-%d-%H-%M-%S')" - mkdir "$d" - mv "$destdir"/* "$d/" + rm -r "$destdir"/* ;; show) show