From aafae21e3912d50f7a2dad102da07725e2ee5566 Mon Sep 17 00:00:00 2001 From: Zane Schaffer Date: Wed, 12 Oct 2022 11:34:50 -0700 Subject: [PATCH] Add tree(1) .info --- .info | 10 +++++++ gen | 25 +++++++++++++++++ generate.sh | 20 -------------- index.html | 13 ++++----- scripts/.info | 2 ++ scripts/generate.sh | 2 ++ scripts/index.html | 25 +++++++++++++++++ scripts/to | 65 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 136 insertions(+), 26 deletions(-) create mode 100644 .info create mode 100755 gen delete mode 100755 generate.sh create mode 100644 scripts/.info create mode 100755 scripts/generate.sh create mode 100644 scripts/index.html create mode 100755 scripts/to diff --git a/.info b/.info new file mode 100644 index 0000000..e436368 --- /dev/null +++ b/.info @@ -0,0 +1,10 @@ +facts.txt + facts about zane schaffer +contact.txt + zane schaffer's contact info +about.txt + general information about zane schaffer +posts + zane schaffer's blog posts +images + zane schaffer's images diff --git a/gen b/gen new file mode 100755 index 0000000..3c57e90 --- /dev/null +++ b/gen @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +BLOG_DIR=${BLOG_DIR:-$PWD} +BLOG_TITLE="zane.town" +BLOG_URL="https://$BLOG_TITLE" +POSTS_DIR="$BLOG_DIR/posts" +IMAGES_DIR="$BLOG_DIR/images" +TREE_FLAGS="--dirsfirst --info -C -L 1" +TREE_IGNORES="-I gen -I index.html" + +tree $TREE_FLAGS $TREE_IGNORES -H $BLOG_URL -T $BLOG_TITLE > index.html + +if [ -f "$IMAGES_DIR/generate.sh" ]; then + cd $IMAGES_DIR && sh "$IMAGES_DIR/generate.sh" +else + echo "images/generate.sh not found" +fi + +if [ -f "$POSTS_DIR/generate.sh" ]; then + cd $POSTS_DIR && sh "$POSTS_DIR/generate.sh" +else + echo "posts/generate.sh not found" +fi + +echo "Done!" diff --git a/generate.sh b/generate.sh deleted file mode 100755 index 1c49ea1..0000000 --- a/generate.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh -DIR=$PWD -POSTS="$DIR/posts" -IMAGES="$DIR/images" - -tree --dirsfirst -C -L 1 -I generate.sh -I dotfiles -I index.html -I tmp -H https://zane.town -T zane.town > index.html - -if [ -f "$IMAGES/generate.sh" ]; then - cd $IMAGES && sh "$IMAGES/generate.sh" -else - echo "images/generate.sh not found" -fi - -if [ -f "$POSTS/generate.sh" ]; then - cd $POSTS && sh "$POSTS/generate.sh" -else - echo "posts/generate.sh not found" -fi - -echo "Done!" diff --git a/index.html b/index.html index 1b75ce0..f162a3b 100755 --- a/index.html +++ b/index.html @@ -17,14 +17,15 @@ https://zane.town
├── cv
├── git
- ├── images
- ├── posts
- ├── about.txt
- ├── contact.txt
- └── facts.txt
+ ├── images
+ ├── posts
+ ├── scripts
+ ├── about.txt
+ ├── contact.txt
+ └── facts.txt


-4 directories, 3 files +5 directories, 3 files

diff --git a/scripts/.info b/scripts/.info new file mode 100644 index 0000000..c6ef0bf --- /dev/null +++ b/scripts/.info @@ -0,0 +1,2 @@ +to + todo list manager diff --git a/scripts/generate.sh b/scripts/generate.sh new file mode 100755 index 0000000..f769eb8 --- /dev/null +++ b/scripts/generate.sh @@ -0,0 +1,2 @@ +#!/bin/sh +tree --dirsfirst --info -C -L 1 -I generate.sh -I index.html -H "https://zane.town/scripts" -T "zane.town/scripts" > index.html diff --git a/scripts/index.html b/scripts/index.html new file mode 100644 index 0000000..e2f8199 --- /dev/null +++ b/scripts/index.html @@ -0,0 +1,25 @@ + + + + + + + zane.town/scripts + + + +

+ https://zane.town/scripts
+ └── to
+

+ +0 directories, 1 file + +

+ + diff --git a/scripts/to b/scripts/to new file mode 100755 index 0000000..0e93281 --- /dev/null +++ b/scripts/to @@ -0,0 +1,65 @@ +#!/usr/bin/env sh +set -eu + +TODO_DIR="${TODO_DIR:-$HOME/.todo}" +TODO_FILE="$TODO_DIR/todo.txt" + +list_items() +{ + if ! [ -s "$TODO_FILE" ]; then + echo "todo.txt is empty." + fi + while IFS= read -r line + do + echo "$line" + done < "$TODO_FILE" +} + +add_item() +{ + echo "$@" >> "$TODO_FILE" + echo "Added: $*" +} + +usage() { echo "to -[healv] " 1>&2; exit; } +version() { echo "to 0.1.0" 1>&2; exit; } + +if [ ! -f "$TODO_FILE" ]; then + while : + do + printf "%s does not exist.\nWould you like to create it? [Y/n] " "$TODO_FILE" + read -r CREATE + CREATE=${CREATE:-y} + case $CREATE in + Y|y) + touch "$TODO_FILE" + echo "Created $TODO_FILE" + break + ;; + n) + echo "Exiting without creating file!" + exit + ;; + *) + ;; + esac +done +fi + +while getopts 'hea:lv' opt; do + opt=${opt:-l} + case $opt in + (h) usage;; + (e) "$EDITOR" "$TODO_FILE";; + (a) add_item ${OPTARG};; + (l) list_items;; + (v) version;; + (?) exit 1;; + esac +done + +if (( $OPTIND == 1 )); then + list_items +fi + +