[download]

local/bin/wikipedia-menu

   1 #!/bin/bash
   2 
   3 f=~/.cache/wikipedia && touch $f
   4 s=$(tac $f | awk '!a[$0]++' | menu -i wikipedia)
   5 
   6 [[ $s ]] && echo "$s" >> $f || exit
   7 [[ ${s//[a-z]} != "$s" ]] && lang=en || lang=ru
   8 
   9 api="https://$lang.wikipedia.org/w/api.php"
  10 api+='?action=query&format=json&prop=extracts|info'
  11 api+='&generator=search&inprop=url&exsentences=1'
  12 api+='&exlimit=max&exintro&explaintext&redirects'
  13 
  14 curl -sd "gsrsearch=$s" $api | jq '.query.pages[] |
  15 .title + ": " + .extract + " " + .fullurl' |
  16 sed 's/^"//; s/"$//' | menu -i wikipedia -p "$s" -l 15 |
  17 awk '{ print $NF }'  | while read i; do chromium "${i/$lang/$lang.m}" & done