l 5: add urban

This commit is contained in:
lassulus 2016-04-13 16:40:33 +02:00
parent f0863085c7
commit 5509ed2263
2 changed files with 22 additions and 0 deletions

View File

@ -10,6 +10,7 @@
}; };
mk_sql_pair = pkgs.callPackage ./mk_sql_pair/default.nix {}; mk_sql_pair = pkgs.callPackage ./mk_sql_pair/default.nix {};
mpv-poll = pkgs.callPackage ./mpv-poll/default.nix {}; mpv-poll = pkgs.callPackage ./mpv-poll/default.nix {};
urban = pkgs.callPackage ./urban/default.nix {};
xmonad-lass = xmonad-lass =
let src = pkgs.writeNixFromCabal "xmonad-lass.nix" ./xmonad-lass; in let src = pkgs.writeNixFromCabal "xmonad-lass.nix" ./xmonad-lass; in
pkgs.haskellPackages.callPackage src {}; pkgs.haskellPackages.callPackage src {};

View File

@ -0,0 +1,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
'
''