Skip to content

Commit

Permalink
Change inline code to code blocks (#1426)
Browse files Browse the repository at this point in the history
for syntax highlighting

as discussed in PR #1425
  • Loading branch information
Kissaki committed May 30, 2024
1 parent 026e0f5 commit 9538f61
Showing 1 changed file with 65 additions and 13 deletions.
78 changes: 65 additions & 13 deletions book/cheat_sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

## Data types

convert string to integer: `"12" | into int`
convert string to integer:

convert present date to provided time zone: `date now | date to-timezone "Europe/London"`
```nu
"12" | into int
```

convert present date to provided time zone:

```nu
date now | date to-timezone "Europe/London"
```

update a record's language and if none is specified insert provided value:

```nu
{'name': 'nu', 'stars': 5, 'language': 'Python'} | upsert language 'Rust'
```

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

convert list of strings to yaml: `[one two three] | to yaml`
```nu
[one two three] | to yaml
```

print table data:

print table data: `[[framework, language]; [Django, Python] [Laravel, PHP]]`
```nu
[[framework, language]; [Django, Python] [Laravel, PHP]]
```

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

Expand Down Expand Up @@ -233,9 +253,17 @@ slice items that satisfy provided condition:

## Tables

sort table: `ls | sort-by size`
sort table:

sort table, get first rows: `ls | sort-by size | first 5`
```nu
ls | sort-by size
```

sort table, get first rows:

```nu
ls | sort-by size | first 5
```

concatenate two tables with same columns:

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

## Files & Filesystem

open a text file with the default text editor: `start file.txt`
open a text file with the default text editor:

```nu
start file.txt
```

save a string to text file:

save a string to text file: `'lorem ipsum ' | save file.txt`
```nu
'lorem ipsum ' | save file.txt
```

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

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

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

watch a file, run command whenever it changes: `watch . --glob=**/*.rs {|| cargo test }`
```nu
{ a: 1, b: 2 } | save file.json
```

recursively search for files by file name:

```nu
glob **/*.{rs,toml} --depth 2
```

watch a file, run command whenever it changes:

```nu
watch . --glob=**/*.rs {|| cargo test }
```

## Custom Commands

Expand Down

0 comments on commit 9538f61

Please sign in to comment.