Skip to content

Commit 9538f61

Browse files
authored
Change inline code to code blocks (#1426)
for syntax highlighting as discussed in PR #1425
1 parent 026e0f5 commit 9538f61

File tree

1 file changed

+65
-13
lines changed

1 file changed

+65
-13
lines changed

book/cheat_sheet.md

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,35 @@
22

33
## Data types
44

5-
convert string to integer: `"12" | into int`
5+
convert string to integer:
66

7-
convert present date to provided time zone: `date now | date to-timezone "Europe/London"`
7+
```nu
8+
"12" | into int
9+
```
10+
11+
convert present date to provided time zone:
12+
13+
```nu
14+
date now | date to-timezone "Europe/London"
15+
```
16+
17+
update a record's language and if none is specified insert provided value:
18+
19+
```nu
20+
{'name': 'nu', 'stars': 5, 'language': 'Python'} | upsert language 'Rust'
21+
```
822

9-
update a record's language and if none is specified insert provided value: `{'name': 'nu', 'stars': 5, 'language': 'Python'} | upsert language 'Rust'`
23+
convert list of strings to yaml:
1024

11-
convert list of strings to yaml: `[one two three] | to yaml`
25+
```nu
26+
[one two three] | to yaml
27+
```
28+
29+
print table data:
1230

13-
print table data: `[[framework, language]; [Django, Python] [Laravel, PHP]]`
31+
```nu
32+
[[framework, language]; [Django, Python] [Laravel, PHP]]
33+
```
1434

1535
select two named columns from the table and print their values:
1636

@@ -233,9 +253,17 @@ slice items that satisfy provided condition:
233253

234254
## Tables
235255

236-
sort table: `ls | sort-by size`
256+
sort table:
237257

238-
sort table, get first rows: `ls | sort-by size | first 5`
258+
```nu
259+
ls | sort-by size
260+
```
261+
262+
sort table, get first rows:
263+
264+
```nu
265+
ls | sort-by size | first 5
266+
```
239267

240268
concatenate two tables with same columns:
241269

@@ -268,17 +296,41 @@ remove the last column of a table:
268296

269297
## Files & Filesystem
270298

271-
open a text file with the default text editor: `start file.txt`
299+
open a text file with the default text editor:
300+
301+
```nu
302+
start file.txt
303+
```
304+
305+
save a string to text file:
272306

273-
save a string to text file: `'lorem ipsum ' | save file.txt`
307+
```nu
308+
'lorem ipsum ' | save file.txt
309+
```
274310

275-
append a string to the end of a text file: `'dolor sit amet' | save --append file.txt`
311+
append a string to the end of a text file:
276312

277-
save a record to file.json: `{ a: 1, b: 2 } | save file.json`
313+
```nu
314+
'dolor sit amet' | save --append file.txt
315+
```
278316

279-
recursively search for files by file name: `glob **/*.{rs,toml} --depth 2`
317+
save a record to file.json:
280318

281-
watch a file, run command whenever it changes: `watch . --glob=**/*.rs {|| cargo test }`
319+
```nu
320+
{ a: 1, b: 2 } | save file.json
321+
```
322+
323+
recursively search for files by file name:
324+
325+
```nu
326+
glob **/*.{rs,toml} --depth 2
327+
```
328+
329+
watch a file, run command whenever it changes:
330+
331+
```nu
332+
watch . --glob=**/*.rs {|| cargo test }
333+
```
282334

283335
## Custom Commands
284336

0 commit comments

Comments
 (0)