added some new note related scripts

This commit is contained in:
Solomon Laing 2023-01-27 22:04:26 +10:30
parent 688b0965f2
commit 64426e1613
4 changed files with 70 additions and 3 deletions

View File

@ -39,9 +39,9 @@ case "$ext" in
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;; java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;; m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then md) if [ -x "$(command -v lowdown)" ]; then
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff > "$base.pdf" groffdown -i "$file" | groff -T pdf > "$base".pdf
else else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;; fi ; ;;
@ -51,7 +51,7 @@ case "$ext" in
py) python "$file" ;; py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;; rs) cargo build ;;
sass) sassc -a "$file" "$base.css" ;; sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;; scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;; sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;; tex) textype "$file" ;;

13
scripts/setvol Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
default_loc=/tmp/pactl-default-sink
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(cat $default_loc)
value=$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")
pactl set-sink-volume $default $value%

40
scripts/zk-gen-dir-md-toc Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Generates a simple index of the current folder and subfolders creating
# a table of contents of all of the .md files contained within.
long_contents=$(find . | sort)
# replace the absolute path in all lines
contents=${long_contents//\.\//}
prev=""
echo "$contents" | while read -r line || [[ -n $line ]];
do
# the line contains a file, or hidden dir
if [[ $line == *"."* ]]; then
# if the line is an md, not in the .zk dir, and not a dir
if [[ $line == *".md"* && ! -d "$line" && $line != *".zk"* ]]; then
# extract the name of the file
name=$(echo "$line" | sed 's/.*\///' | sed 's/\.md//')
# create the link
name="[$name]($line)"
else
continue
fi
else
# the folders are titles
name=$(echo -e "\n## $line")
fi
# two titles in a row means empty folder.
if [[ $prev == *"##"* && $name == *"##"* ]]; then
prev=$name
name=$(echo -e "Folder Empty.\n$prev")
else
prev=$name
fi
echo "$name"
done

14
scripts/zk-gen-index Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
toc=$(./toc.sh)
echo -e "START_TOC\n$toc\n\nEND_TOC" > temp.md
if [ -f index.md ]; then
perl -i -p0e 's/START_TOC.*END_TOC/`cat temp.md`/se' index.md
# sed -i "s/START_TOC.*END_TOC/\${toc}/g" index.md
else
echo -e "# Index \n\n START_TOC \n $toc \n END_TOC" > index.md
fi
rm temp.md