diff --git a/scripts/md b/scripts/md index 4b3a19b..8fb02d7 100755 --- a/scripts/md +++ b/scripts/md @@ -1,47 +1,4 @@ -#!/usr/bin/env bash - -## 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 +#!/bin/sh +test -z "$@" && test -f ./README.md && exec glow -p ./README.md +exec glow -p "$@"