summaryrefslogtreecommitdiffstats
path: root/lass/5pkgs/urban/default.nix
blob: fb8adaed9d705aa6585ebe176bd035956d3231f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{ pkgs, ... }:

pkgs.writeScriptBin "urban" ''
  #!/bin/sh
  set -euf
  term=$1
  curl -LsS 'http://www.urbandictionary.com/define.php?term='"$term" \
    | sed 's/<\/\?a\>[^>]*>//g' \
    | sed 's/<\([^>]*\)>/\n<\1\n/g' \
    | grep . \
    | sed -n '/<div class=.meaning./,/<\/div/p' \
    | sed 's/<div class=.meaning./-----/' \
    | grep -v '^</div\>' \
    | grep -v '^<br\>' \
    | sed '
      s/&quot;/"/g
      s/&#39;/'\'''/g
      s/&gt;/>/g
      s/&lt;/>/g
    '
''