alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

notetag (1029B) [raw]


      1 #!/bin/sh
      2 # notetag -- small program to sort notes into tagged dirs
      3 set -e
      4 die() {
      5     echo "$*" 1>&2
      6     exit 1
      7 }
      8 
      9 [ -d all ] || die "ERROR: unable to find the 'all' notes directory; check cwd"
     10 
     11 for f in all/*; do
     12     tags=$(grep '^tags:' "$f" | sed 's/tags: //')
     13     tags=${tags:-misc}
     14     for t in $tags; do
     15         mkdir -p "$t"
     16         (cd "$t" && ln -sf "../$f")
     17     done
     18 done
     19 
     20 cat <<'EOM'
     21 my technical
     22               __
     23              /\ \__
     24   ___     ___\ \ ,_\    __    ____
     25 /' _ `\  / __`\ \ \/  /'__`\ /',__\
     26 /\ \/\ \/\ \L\ \ \ \_/\  __//\__, `\
     27 \ \_\ \_\ \____/\ \__\ \____\/\____/
     28  \/_/\/_/\/___/  \/__/\/____/\/___/
     29 
     30 No warranty / use at your own risk!
     31 
     32 
     33 
     34 EOM
     35 
     36 for tag in */; do
     37     count="$(ls "$tag" | wc -l | sed 's/^[[:space:]]*//')"
     38     if [ "$count" = "1" ]; then
     39         printf "[1| %-24s  %4s note)|%s|server|port]\n" "$tag" "($count" "$tag"
     40     else
     41         printf "[1| %-24s %4s notes)|%s|server|port]\n" "$tag" "($count" "$tag"
     42     fi
     43 done
     44 
     45 cat <<EOM
     46 
     47 
     48 [1|<-- Home|/|server|port]
     49 
     50 Last Updated: $(date)
     51 EOM