scripts

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

commit 4783bada354aa74c4c186f78e48b363e0a4d7fb7
parent 5ae4e1ed091fc9dfb8a140f23788c7844385aeac
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 14 Apr 2024 09:23:38 +0200

Added xcenters to alg

Diffstat:
Malg | 54++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/alg b/alg @@ -6,7 +6,7 @@ # Example: alg c UBL E - prints out all first algs for UBL-FDR-* usage() { - echo "Usage: alg [[edit] (c|e|w) [buffer] (1 letter|2 letters)]" + echo "Usage: alg [[edit] (c|e|w|x) [buffer] (1 letter|2 letters)]" } default_editor=vi @@ -14,6 +14,7 @@ basedir="$HOME/box/speedcubing/bld/algs" ebuffer=UR cbuffer=UFR wbuffer=UFr +xbuffer=Ubl edge() { [ "$1" = "a" ] && echo FU @@ -86,10 +87,36 @@ wing() { [ "$1" = "u" ] && echo BRd [ "$1" = "v" ] && echo LFu [ "$1" = "w" ] && echo LBd - [ "$1" = "x" ] && echo LUf + [ "$1" = "x" ] && echo RUf [ "$1" = "z" ] && echo RFd } +xcenter() { + [ "$1" = "a" ] && echo Ful + [ "$1" = "b" ] && echo Ufr + [ "$1" = "c" ] && echo Ufl + [ "$1" = "d" ] && echo Ubr + [ "$1" = "e" ] && echo Fdr + [ "$1" = "f" ] && echo Rdb + [ "$1" = "g" ] && echo Ldf + [ "$1" = "i" ] && echo Fur + [ "$1" = "j" ] && echo Luf + [ "$1" = "k" ] && echo Rub + [ "$1" = "l" ] && echo Dfr + [ "$1" = "m" ] && echo Dbr + [ "$1" = "n" ] && echo Dfl + [ "$1" = "o" ] && echo Fdl + [ "$1" = "p" ] && echo Dbl + [ "$1" = "r" ] && echo Bur + [ "$1" = "s" ] && echo Bul + [ "$1" = "t" ] && echo Bdl + [ "$1" = "u" ] && echo Bdr + [ "$1" = "v" ] && echo Lub + [ "$1" = "w" ] && echo Ldb + [ "$1" = "x" ] && echo Ruf + [ "$1" = "z" ] && echo Rdf +} + edit() { mkdir -p "$basedir/$1/$2/$3" $editor "$basedir/$1/$2/$3/$4" @@ -137,6 +164,20 @@ showall_w() { done } +showall_x() { + all_letters="a b c d e f g i j k l m n o p r s t u v w x z" + buffer="$1" + firstletter="$2" + firsttarget="$(xcenter $firstletter)" + for secondletter in $all_letters; do + secondtarget="$(xcenter $secondletter)" + f="$basedir/xcenters/$buffer/$firsttarget/$secondtarget" + [ -f "$f" ] || continue + line="$(head -n 1 "$f")" + printf '%s %s\n' "$firstletter$secondletter" "$line" + done +} + run() { if [ "$1" = "edit" ]; then editor="$default_editor" @@ -153,6 +194,7 @@ run() { cbuffer="$2" ebuffer="$2" wbuffer="$2" + xbuffer="$2" fi letter1="$(echo "$letters" | cut -c 1)" @@ -183,6 +225,14 @@ run() { showall_w $wbuffer $letter1 fi ;; + x) + if [ -n "$letter2" ]; then + edit xcenters $xbuffer $(xcenter $letter1) \ + $(xcenter $letter2) + else + showall_x $xbuffer $letter1 + fi + ;; *) usage && return ;;