mirror of https://github.com/rwxrob/dot
fix: md
parent
47a5048154
commit
07f5a10232
@ -1,47 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
## See, now *this* is why using only hashtag headers in Markdown are so
|
|
||||||
## essential. Imagine doing this if level one and two headers could
|
|
||||||
## also be the stupid underline style.
|
|
||||||
|
|
||||||
toc () {
|
|
||||||
declare file=$(mktemp)
|
|
||||||
#TODO make it smarter, just need something quick for now
|
|
||||||
echo cat $file
|
|
||||||
while IFS= read -r line;do
|
|
||||||
if [[ $line =~ ^#+\ ]]; then
|
|
||||||
echo $line >> $file
|
|
||||||
fi
|
|
||||||
echo "$line"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
imagelinks () {
|
|
||||||
declare dir="${1-.}"
|
|
||||||
find "$dir" -regextype posix-extended -regex '.+(png|jpg|gif)$' -printf "![](%p)\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
########################## Command Delegation ##########################
|
|
||||||
|
|
||||||
declare subcommand="$1"; shift
|
|
||||||
declare -a commands=( toc imagelinks)
|
|
||||||
|
|
||||||
######################### Tab Completion Context ########################
|
|
||||||
|
|
||||||
if [ -n "$COMP_LINE" ]; then
|
|
||||||
pre=${COMP_LINE#* }
|
|
||||||
for cmd in ${commands[@]}; do
|
|
||||||
[[ $cmd =~ ^$pre ]] && echo $cmd
|
|
||||||
done
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
###################### Regular Context Delegation ######################
|
|
||||||
|
|
||||||
for i in ${commands[@]}; do
|
|
||||||
if [[ $i == "$subcommand" ]]; then
|
|
||||||
"$subcommand" $*
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
test -z "$@" && test -f ./README.md && exec glow -p ./README.md
|
||||||
|
exec glow -p "$@"
|
||||||
|
Loading…
Reference in New Issue