[download]

local/bin/bloge-menu

   1 #!/bin/bash
   2 
   3 cd ~/Wiki || exit 1
   4 icon=$(icon document)
   5 wiki(){ # {{{
   6     declare -A pages tags heads
   7 
   8     while       read a b; do pages[$b]=$a;   done < <(find 202*.wiki -printf '%T+ %p\n')
   9     while IFS=: read a b; do tags[$a]+="$b"; done < <(grep -io ':[0-9a-zа-я:_-]\+:' "${!pages[@]}")
  10     while IFS=: read a b; do heads[$a]="$b"; done < <(grep -io '^= [^=]*' "${!pages[@]}")
  11 
  12     for page in "${!pages[@]}"; do
  13         time=${pages[$page]}
  14         tags=${tags[$page]}
  15         tags=${tags//::/:}
  16         head=${heads[$page]#= }
  17 
  18         printf '%s\t%s\t%s\t%s\n' "$time" "$icon ${page%.wiki}" "$head" "${tags:-:безтемы:}"
  19     done
  20 } # }}}
  21 
  22 while read _ i; do
  23     gvim "$i.wiki" &
  24 done < <(
  25     wiki |
  26     sort -r | cut -f 2- |
  27     column -ts $'\t'    |
  28     menu -i bloge -l 20 |
  29     sed 's/ [^ ]*$//'
  30 )