Skip to content

Commit

Permalink
Add Nushell birthday post (#1019)
Browse files Browse the repository at this point in the history
* Add Nushell birthday post

* add more

* add more content

* add more content

* add more content
  • Loading branch information
sophiajt committed Aug 24, 2023
1 parent 2616e6a commit d226eea
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
Binary file added assets/images/bday_4_bulk_convert.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bday_4_grid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bday_4_hex_colours.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bday_4_subcommand_help.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions blog/2023-08-23-happy-birthday-nushell-4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: Celebrating 4 years of Nushell
author: The Nu Authors
author_site: https://twitter.com/nu_shell
author_image: https://www.nushell.sh/blog/images/nu_logo.png
excerpt: Today, we're celebrating 4 years since Nushell's first public release.
---

# Nushell turns 4 years old!

Today marks 4 years since Nushell's [first public release](https://www.nushell.sh/blog/2019-08-23-introducing-nushell.html). In that time, Nushell has grown and changed, while always staying true to the idea that started it all: being a structure data language and shell.

To celebrate, we thought we'd share stories of how people are using Nushell today.

## Watching for database changes (Reilly)

- in a loop, clear the screen, do something like `open app.db | get some_table`, and then `sleep` a few seconds to provide an auto-updating "dashboard" of what's going on in a SQLite database
- use `watch` to run a SQLite command whenever a .sql file changes - kinda like a poor man's SQLite IDE

## Using a `grid` when you `cd` (fdncred)

"I have it in a custom command name lsg and then in my env_change hook on the PWD env var, I call print (lsg). So, every time I cd, lsg gets ran for whatever directory I'm cd'ing to, automatically."

Using `ls | sort-by type name -i | grid -c`, it looks like this:

![Grid showing pretty sorted items with pretty colours](../assets/images/bday_4_grid.png)

## Converting SVG to PDF in bulk (sholderbach)

"Converting SVG drawings and figures to PDFs in bulk. I like how explicit and clean that is compared to a solution with xargs in bash"

![Highlighted source converting files using path parse, where, and inkspace](../assets/images/bday_4_bulk_convert.jpeg)

## Gotta have a Chuck Norris joke

```nushell
> (http get https://api.chucknorris.io/jokes/random).value
```

## Surprise, we support script subcommands (jt)

"Turns out, we already support subcommands in scripts."

```
# adds 100 to the argument
def "main foo" [
x: int # the amount to start with
] {
print ($x + 100)
}
def "main" [] {
print "usage: maintest.nu <command name>"
}
```

```
> nu ../maintest.nu foo 123
223
```

It even comes with its own help
![automated help generated for the script subcommand](../assets/images/bday_4_subcommand_help.png)

## Crossplatform simlinks (Kubouch)

"Here is my favorite: Cross-platform symlink:"

```nushell
# Create a symlink
export def symlink [
existing: path # The existing file
link_name: path # The name of the symlink
] {
let existing = ($existing | path expand -s)
let link_name = ($link_name | path expand)
if $nu.os-info.family == 'windows' {
if ($existing | path type) == 'dir' {
mklink /D $link_name $existing
} else {
mklink $link_name $existing
}
} else {
ln -s $existing $link_name | ignore
}
}
```

## Giving your hex values some color (fdncred)

add `string: {|x| if $x =~ '^#[a-fA-F\d]+' { $x } else { 'white' } }` to your `$env.config.color_config` and you'll get:

![screenshot showing each hex value colored to match the color of that hex value](../assets/images/bday_4_hex_colours.png)

# And many more

We've hope you all have enjoyed using Nushell as much as we've enjoyed making. Here's to many more happy birthdays to come!

0 comments on commit d226eea

Please sign in to comment.