[download]

local/bin/wiki-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 *.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 wiki |
  23 sort -r | cut -f 2- |
  24 column -ts $'\t'    |
  25 menu -i wiki -l 20  |
  26 awk -F '   *' '{ print $2 }' |
  27 xargs -rI % gvim %.wiki