blob: fdfba4f684a0f47f4d68269669d8b2bfb6a7c7f4 [file] [log] [blame]
Florian Baumann02d65af2010-11-10 20:25:40 +01001# based on https://gist.github.com/318247
2
3# Usage: browser
4# pipe html to a browser
5# e.g.
6# $ echo "<h1>hi mom!</h1>" | browser
7# $ ron -5 man/rip.5.ron | browser
8
9function browser() {
10 if [ -t 0 ]; then
11 if [ -n "$1" ]; then
12 open $1
13 else
14 cat <<usage
15Usage: browser
16pipe html to a browser
17
18$ echo '<h1>hi mom!</h1>' | browser
19$ ron -5 man/rip.5.ron | browser
20usage
21
22 fi
23
24 else
25 f="/tmp/browser.$RANDOM.html"
26 cat /dev/stdin > $f
27 open $f
28 fi
29}
Robert Lowe63a00c72011-03-07 23:16:18 -050030
31
32# pipe hot spicy interwebs into textmate and cleanup!
33#
34# Usage: wmate
35# wget into a pipe into TextMate and force Tidy (you can undo in textmate)
36# e.g.
37# $ wmate google.com
38
39function wmate() {
40 if [ -t 0 ]; then
41 if [ -n "$1" ]; then
42 wget -qO- $1 | /usr/bin/mate
43
44TIDY=`/usr/bin/osascript << EOT
45tell application "TextMate"
46 activate
47end tell
48
49tell application "System Events"
50 tell process "TextMate"
51 tell menu bar 1
52 tell menu bar item "Bundles"
53 tell menu "Bundles"
54 tell menu item "HTML"
55 tell menu "HTML"
56 click menu item "Tidy"
57 end tell
58 end tell
59 end tell
60 end tell
61 end tell
62 end tell
63end tell
64EOT`
65
66 else
67 cat <<usage
68Usage: wmate google.com
69wget into a pipe into TextMate and force Tidy (you can undo in textmate)
70
71$ wmate google.com
72usage
73
74 fi
75 fi
76}
77
78#
79# Usage: raw google.com
80# wget into a temp file and pump it into your browser
81#
82# e.g.
83# $ raw google.com
84function raw() {
85 if [ -t 0 ]; then
86 if [ -n "$1" ]; then
87 wget -qO- $1 | browser
88 else
89 cat <<usage
90Usage: raw google.com
91wget into a temp file and pump it into your browser
92
93$ raw google.com
94usage
95 fi
96 fi
97}