From 64426e1613d914e6e7a8f9597e9cc3ada3c4aa04 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Fri, 27 Jan 2023 22:04:26 +1030 Subject: [PATCH] added some new note related scripts --- scripts/compiler | 6 +++--- scripts/setvol | 13 +++++++++++++ scripts/zk-gen-dir-md-toc | 40 +++++++++++++++++++++++++++++++++++++++ scripts/zk-gen-index | 14 ++++++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 scripts/setvol create mode 100755 scripts/zk-gen-dir-md-toc create mode 100755 scripts/zk-gen-index diff --git a/scripts/compiler b/scripts/compiler index 6e28cd0..8420e25 100755 --- a/scripts/compiler +++ b/scripts/compiler @@ -39,9 +39,9 @@ case "$ext" in java) javac -d classes "$file" && java -cp classes "${1%.*}" ;; m) octave "$file" ;; 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 - groffdown -i "$file" | groff > "$base.pdf" + groffdown -i "$file" | groff -T pdf > "$base".pdf else pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file" fi ; ;; @@ -51,7 +51,7 @@ case "$ext" in py) python "$file" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; rs) cargo build ;; - sass) sassc -a "$file" "$base.css" ;; + sass) sassc -a "$file" "$base".css ;; scad) openscad -o "$base".stl "$file" ;; sent) setsid -f sent "$file" 2>/dev/null ;; tex) textype "$file" ;; diff --git a/scripts/setvol b/scripts/setvol new file mode 100755 index 0000000..2b6a000 --- /dev/null +++ b/scripts/setvol @@ -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% diff --git a/scripts/zk-gen-dir-md-toc b/scripts/zk-gen-dir-md-toc new file mode 100755 index 0000000..f3bcd47 --- /dev/null +++ b/scripts/zk-gen-dir-md-toc @@ -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 diff --git a/scripts/zk-gen-index b/scripts/zk-gen-index new file mode 100755 index 0000000..81c2879 --- /dev/null +++ b/scripts/zk-gen-index @@ -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