-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
253 lines (222 loc) · 9.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html lang="en">
<head>
<title>dt: duck tape for your unix pipes</title>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css">
<link rel="stylesheet" href="style.css">
<!-- Thanks to https://favicomatic.com -->
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="apple-touch-icon-57x57.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144.png">
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="apple-touch-icon-60x60.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="apple-touch-icon-120x120.png">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="apple-touch-icon-76x76.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="favicon-128.png" sizes="128x128">
<!-- Social media stuff -->
<meta property="og:url" content="https://dt.plumbing/">
<meta property="og:title" content="dt: duct tape for unix pipes">
<meta property="og:description" content="dt is a functional programming riff on shell one-liners. It's useful for many situations, its simple syntax makes it easy to write and read, and dt is for solving problems with no pretense of elegance. It's meant to supplement (not replace!) other tools like awk, sed, xargs, and shell built-ins. A functional programming riff on Python/Ruby/Perl one-liners, with extremely minimal syntax that's easy to read and easy to reason about. ">
<meta property="og:image" content="https://dt.plumbing/img/preview.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="640">
<meta property="og:image:height" content="320">
<meta name="application-name" content=" ">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="mstile-144x144.png">
<meta name="msapplication-square70x70logo" content="mstile-70x70.png">
<meta name="msapplication-square150x150logo" content="mstile-150x150.png">
<meta name="msapplication-wide310x150logo" content="mstile-310x150.png">
<meta name="msapplication-square310x310logo" content="mstile-310x310.png">
<!-- /favicons -->
</head>
<body>
<div id="strip">
<header class='center'>
<h1 id="logo">
<img alt="dt" src="/img/dt-logo-white.svg" height="256" width="256">
</h1>
<h2><code>duct tape for your unix pipes</code></h2>
</header>
<main>
<hr>
<!-- toc -->
<div class='center'>
<h2><a id="toc"></a>Quick Links</h2>
<ul class="nodecorate">
<li><a href="#intro">What's dt?</a></li>
<li>⌾</li>
<li><a href="#pipes">Pipes</a></li>
<li><a href="#shebangs">Shebang Scripts</a></li>
<li><a href="#repl">Interactive Mode (REPL)</a></li>
<li>⌾</li>
<li><a href="/user-guide/install.html">Install</a></li>
<li><a href="/user-guide/">User Guide</a></li>
<li><a href="/user-guide/lang/stdlib.html">Standard Library</a></li>
<li>⌾</li>
<li><a href="/user-guide/misc/duct-tape.html">Is it "duct" or "duck" tape?</a></li>
</ul>
</div>
<hr>
<!-- intro -->
<h2 id="intro">What's dt? <a href="#intro">⌾</a></h2>
<p>
<em>dt</em> is a functional programming riff on shell one-liners.
It's useful for many situations, its simple syntax makes it easy to
write and read, and dt is for solving problems with no pretense of
elegance. The philosophy can be summed up with quotes from the
ultimate handyman, <a href="https://www.redgreen.com">Red Green</a>:
</p>
<ul>
<li>If it ain't broke, you're not trying.</li>
<li>...the handyman's secret weapon, duct tape.</li>
<li>This is only temporary, unless it works.</li>
<li>Spare the duct tape, spoil the job.</li>
</ul>
<p>
It's meant to supplement (<i>not replace!</i>) other tools like awk,
sed, xargs, and shell built-ins. A functional programming riff on
Python/Ruby/Perl one-liners, with extremely minimal syntax that's
easy to read and easy to reason about.
</p>
<p>
dt is released as open source software, usable under the (permissive)
terms of <a href="https://opensource.org/licenses/BSD-3-Clause">
the BSD 3-Clause license</a>.
</p>
<hr>
<!-- pipes -->
<h2 id="pipes">Use in Pipes <a href="#pipes">⌾</a></h2>
<p>
When piping in/out, the REPL is skipped. If dt has receives standard
input from a pipe, it's fed to `dt` as a list of lines.
</p>
<pre>
$ seq 3 | dt rev pls
3
2
1
</pre>
<p>Great for aliases:</p>
<pre>
$ alias scream-lines="dt [upcase words unlines] map pls"
$ echo "hey you pikachu" | scream-lines
HEY
YOU
PIKACHU
</pre>
<p>If you want to read lines manually, use `stream` as the first command:</p>
<pre>
$ alias head.dt="dt stream [rl pl] args last to-int times"
$ seq 100 | head.dt 3
1
2
3
</pre>
<hr>
<!-- shebang -->
<h2 id="shebangs">Use in Shebang Scripts <a href="#shebangs">⌾</a></h2>
<p>
When the first argument to `dt` is a file starting with `#!` it will
interpret the file. In short: `dt` supports shebang scripting.
</p>
<p>
A naive tee implementation:
</p>
<pre>tee.dt</pre>
<pre>
#!/usr/bin/env dt
readln unlines \stdin :
args pop \file :
stdin pl
stdin file writef
</pre>
<p>Then use like:</p>
<pre>
cat wish-list | sed 's/red/green/g' | tee.dt new-wish-list
</pre>
<hr>
<!-- repl -->
<h2 id="repl">Using Interactive Mode (REPL) <a href="#repl">⌾</a></h2>
<p>
Running `dt` by itself with no pipes in or out starts a
read-eval-print loop (REPL).
</p>
<pre>
$ dt
dt 1.x.x
Now, this is only temporary... unless it works.
» # Comments start with #
»
» 1 1 + println
2
»
» # Printing is common, so there are a bunch of printing shorthands.
» # "p" is print, "pl" is print line, "pls" is print lines (i.e. of a list of values)
» # Let's define a command that consumes a value, prints it, then returns its double.
»
» [ \n : n p " " p n 2 *] \print-and-double def
»
»
» # And let's do it... 7 times!
»
» 1 \print-and-double 7 times drop
1 2 4 8 16 32 64
»
»
» # You can conditionally execute code
»
» ["hi" pl] false do?
» ["bye" pl] true do?
bye
»
» quit
</pre>
<p>
For a better experience, also install
<a href="https://github.com/hanslub42/rlwrap">rlwrap</a> and set a
shell alias like so:
</p>
<pre>
$ alias dtsh='rlwrap dt'
$ dtsh
dt 1.x.x
Now, this is only temporary... unless it works.
»
</pre>
<p>
The above example assumes a bash-like shell. Details on the syntax and
configuration files to set an alias that persists will vary by your shell.
</p>
<hr>
<!-- more -->
<p>To continue learning about dt, consider one of these options:</p>
<ul>
<li><a href="/user-guide/tutorial/install.html">Install</a></li>
<li><a href="/user-guide">User Guide</a></li>
<li><a href="/user-guide/lang/stdlib.html">Standard Library</a></li>
</ul>
</main>
<!-- footer -->
<footer class="lighter center">
<p><a href="https://github.com/so-dang-cool/dt">Project source</a></p>
<p><a href="https://github.com/so-dang-cool/dt.plumbing">Site source</a></p>
<p>
Images:
<a href="https://pic-noodle.blogspot.com/2021/01/piece-of-duct-tape-png-vector-scotch.html">
Duct Tape</a>,
<a href="https://www.goodfreephotos.com/united-states/wisconsin/new-glarus/dark-brewing-room-with-pipes.jpg.php">
Pipes</a>
</p>
<hr>
<p>Remember, I'm pullin' for ya,<br>we're all in this together.</p>
<p>2022 <a href="https://so.dang.cool">Justin Hill</a></p>
</footer>
</div>
</body>
</html>