dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit d59209b7c946494924afb1399b18b6e00a447f25
parent a232e9bf8e9e75b0a53ba673f406f337f01d0238
Author: hhvn <dev@hhvn.uk>
Date:   Sat,  1 Jan 2022 19:11:56 +0000

.s/b/alcl: remove

Diffstat:
D.scripts/bin/alcl | 160-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 160 deletions(-)

diff --git a/.scripts/bin/alcl b/.scripts/bin/alcl @@ -1,160 +0,0 @@ -#!/bin/sh -# -# alcl -# Created by Hayden Hamilton -# -# hayden@haydenvh.com -# Copyright (c) 2020 Hayden Hamilton -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# This work is free. You can redistribute it and/or modify it under the -# terms of the Do What The Fuck You Want To Public License, Version 2, -# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. - -GOPHERDIR="/alcl/write" -PHLOG="$HOME/net/$GOPHERDIR" -RSSBNB="$HOME/net/phlog.rssbnb" -HOSTNAME="haydenvh.com" - -HEAD=" ________ __ ________ __ - _____/ | / / / ____ / / / - ____/ / | / / / / '-' / / - ___/ _ | / / / / / / - __/ / | | / /_____ / /___.-. / /_____ - _/_/ |_| /_______/ /_______/ /_______/ - ---------------------------------------------------------------------------------" - -FOOT="--------------------------------------------------------------------------------" - -sanitise(){ - sed 's/\\:/\&#58;/g;s/\\,/\&#44;/g;s/:/\&#58;/g;s/,/\&#44;/g' < /dev/stdin -} - -_list(){ - for f in $(find $PHLOG/$1 -type f -not -name "*links.gph*" -name "*.gph" -o -name "*.txt") - do - echo "$(echo "$f" | awk -F"/" '{print $NF}' | sed 's~-.*$~~')##$f" - done | sort -r | sed "s/^.*##//;s~$PHLOG/$1[/]*~~g" | - while IFS= read -r line - do - echo "$line $(grep '^#[[:space:]A-Z0-9a-z]' < $PHLOG/$1/$line)" - done | head -n "$(($(tput lines)-2))" -} - -_new(){ - [ ! -z "$1" ] && { - dir="$PHLOG/$1" - gopherdir="$GOPHERDIR/$1" - } || { - echo "$(find $PHLOG/ -type d | sed "s~$PHLOG/~~" | tr '\n' ' ')" - printf 'Dir? ' - read _dir < /dev/tty - [ ! -z $_dir ] && { - dir="$PHLOG/$_dir" - gopherdir="$GOPHERDIR/$_dir" - } || { - dir="$PHLOG" - gopherdir="$GOPHERDIR" - } - } - printf "Entry title? " && read name < /dev/tty - num=$(find $PHLOG/ -name "*.txt" -o -name "*.gph" -not -name "*links.gph" | wc -l) - num=$(($num+1)) - filename="$(printf "%05d" "$num")-$(echo "$name" | tr '[[:space:]]' '.' | tr '[:upper:]' '[:lower:]' | tr -dc '[A-Za-z0-9-.+=%#!]' | sed 's/\.\./\./g')" - printf "gph or txt? " && read filetype < /dev/tty - [ -f $dir/$filename$filetype ] && echo "Entry already exists... quitting" && exit 1 - case "$filetype" in - gph) gophertype="1";; - *) gophertype="0";; - esac - printf "$HEAD\n\n#$name\n\n<++>\n[1|<< comments >>|/alcl/write/comments.dcgi?$num|server|port] \n\n$FOOT\n\n" > $dir/$filename$filetype - $EDITOR $dir/$filename$filetype - - [ ! -f $dir/$filename$filetype ] && { - printf "Cancelling...\nDraft entry moved to $HOME/$filename$filetype, use \`alcl import\` later.\n" - printf "!! FILE: $dir/$filename$filetype\n!! DRAFT PHLOG ENTRY\n" | cat /dev/stdin $dir/$filename$filetype > $HOME/$filename$filetype - exit 2 - } - - [ ! -f $RSSBNB ] && { - printf "No RSSBNB file... creating.\nPhlog title? " - read title < /dev/tty - printf "Phlog link? " - read link < /dev/tty - printf "! Phlog description?\n! All lines starting with '!' are ignored\n" > /tmp/desc.alcl - $EDITOR /tmp/desc.alcl - echo ":main,$(echo "$title" | sanitise),$(echo "$link" | sanitise),$(sed '/^\!/d' < /tmp/desc.alcl | sanitise):" - } - - printf "! Entry description?\n! All lines starting with '!' are ignored.\n" > /tmp/desc.alcl - $EDITOR /tmp/desc.alcl - echo ":sub,$(echo "$name" | sanitise),gopher\://$(echo "$HOSTNAME" | sanitise)/$gophertype$(echo "$gopherdir" | sanitise)/$filename$filetype,$(sanitise < /tmp/desc.alcl | sed '/^\!/d'):" >> $RSSBNB -} - -_import(){ - # check validity - [ $(head -n 2 < "$1" | grep '^!!' | wc -l) -ne 2 ] && echo "Invalid draft file... exiting" && exit 1 - - file=$(head -n 1 < "$1") - file=${file##*FILE: } - - tail -n +3 < "$1" > $file - - $EDITOR $file - [ ! -f $RSSBNB ] && { - printf "No RSSBNB file... creating.\nPhlog title? " - read title < /dev/tty - printf "Phlog link? " - read link < /dev/tty - printf "! Phlog description?\n! All lines starting with '!' are ignored\n" > /tmp/desc.alcl - $EDITOR /tmp/desc.alcl - echo ":main,$(echo "$title" | sanitise),$(echo "$link" | sanitise),$(sed '/^\!/d' < /tmp/desc.alcl | sanitise):" - } - - printf "! Entry description?\n! All lines starting with '!' are ignored\n! Add a single line containing a single char, 'X' to cancel your entry.\n" > /tmp/desc.alcl - $EDITOR /tmp/desc.alcl - sed '/^!/d;/^$/d' | head -n 1 | grep '^X$' >/dev/null && { - printf "Cancelling...\nDraft entry moved to $HOME/${file##*/}, use \`alcl import\` later.\n" - printf "!! FILE: $file\n!! DRAFT PHLOG ENTRY\n" | cat /dev/stdin $file > $HOME/${file##*/} - exit 2 - } - [ "${file##*.}" = "gph" ] && gophertype=1 || gophertype=0 - echo ":sub,$(grep '^#' < $file | head -n 1 | sanitise),gopher\://$(echo "$HOSTNAME" | sanitise)/$gophertype$(echo "$GOPHERDIR" | sanitise)/${file##$PHLOG}$,$(sanitise < /tmp/desc.alcl | sed '/^\!/d'):" >> $RSSBNB -} - -_find(){ - [ "$1" = "" ] && echo "No query" && exit - - files=$(find $PHLOG/ -type f -name "*.gph" -o -name "*.txt" -not -name "links.gph") - - # titles take priority - titles=$(grep "^#[^#].*$1.*" $files | awk -F: '{print $1;print $1;print $1;print $1;print $1}') - - # rest is secondary - contents=$(grep "$1" $files | awk -F: '{print $1}') - - printf "$title\n$contents\n" | sed "s~$PHLOG~$GOPHERDIR~" | uniq -c | tail -n +2 | sort -r -} - - -case "$1" in - ls) _list "$2" ;; - new) _new "$2" ;; - import) _import "$2" ;; - find) _find "$2" ;; - *) echo 'usage: alcl <subcommand> - -SUBCOMMANDS: - ls [dir] - new [dir] - import /path/to/draft - search "query"' ;; -esac