Add tree(1) .info

This commit is contained in:
Zane Schaffer 2022-10-12 11:34:50 -07:00 committed by Zane Schaffer
parent 97677f5c15
commit aafae21e39
8 changed files with 136 additions and 26 deletions

10
.info Normal file
View File

@ -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

25
gen Executable file
View File

@ -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!"

View File

@ -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!"

View File

@ -17,14 +17,15 @@
<a href="https://zane.town">https://zane.town</a><br>
├── <a href="https://zane.town/cv/">cv</a><br>
├── <a href="https://zane.town/git/">git</a><br>
├── <a href="https://zane.town/images/">images</a><br>
├── <a href="https://zane.town/posts/">posts</a><br>
├── <a href="https://zane.town/about.txt">about.txt</a><br>
├── <a href="https://zane.town/contact.txt">contact.txt</a><br>
└── <a href="https://zane.town/facts.txt">facts.txt</a><br>
├── <a title="zane schaffer's images" href="https://zane.town/images/">images</a><br>
├── <a title="zane schaffer's blog posts" href="https://zane.town/posts/">posts</a><br>
├── <a href="https://zane.town/scripts/">scripts</a><br>
├── <a title="general information about zane schaffer" href="https://zane.town/about.txt">about.txt</a><br>
├── <a title="zane schaffer's contact info" href="https://zane.town/contact.txt">contact.txt</a><br>
└── <a title="facts about zane schaffer" href="https://zane.town/facts.txt">facts.txt</a><br>
<br><br><p>
4 directories, 3 files
5 directories, 3 files
</p>
</body>

2
scripts/.info Normal file
View File

@ -0,0 +1,2 @@
to
todo list manager

2
scripts/generate.sh Executable file
View File

@ -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

25
scripts/index.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="color-scheme" content="dark light" />
<link href="favicon.svg" rel="icon" type="image/svg+xml"/>
<title>zane.town/scripts</title>
<style type="text/css">
body {font-family: monospace;}
p { margin:0px; padding: 0px;}
a { text-decoration: none; color: unset; }
a:hover { color: #888; }
</style>
</head>
<body>
<p>
<a href="https://zane.town/scripts">https://zane.town/scripts</a><br>
└── <a title="todo list manager" href="https://zane.town/scripts/to">to</a><br>
<br><br><p>
0 directories, 1 file
</p>
</body>
</html>

65
scripts/to Executable file
View File

@ -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] <string>" 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