dictionary 482 B

123456789101112131415161718
  1. #!/bin/sh
  2. # Requires 'dictd' package
  3. terminal="urxvt -e"
  4. tmpfile="/tmp/ddict.lookup.$$"
  5. word=$(xsel -o | dmenu -p 'Dict Lookup:') || exit
  6. while [[ $word != "" ]]; do
  7. oup=$(dict "$word" 2>&1)
  8. if [[ $? -eq 21 ]]; then
  9. word=$(echo -e "$oup" | cut -d: -f2 | xargs -n1 | sort -u -f | dmenu -sf "#00ff00" -sb "black" -nb "black" -p 'Did you mean:') || exit
  10. else
  11. echo -e "$oup" > "$tmpfile"
  12. break
  13. fi
  14. done
  15. $terminal less "$tmpfile"\; rm "$tmpfile"