Search

Dark theme | Light theme
Showing posts with label NushellNiceties:Misc. Show all posts
Showing posts with label NushellNiceties:Misc. Show all posts

July 15, 2026

Nushell Niceties: Generating Passwords

Since Nushell 0.114.0 you can use the random pass command to generate a random password of 12 characters. Nushell will use a combination of letters, numbers and symbols. It is possible to generate a password with a different length using the command-line option --chars (or -c) followed by the size of the password. The minimal length is 4 characters and the maximum size is 128 characters.

If you don’t want to include symbols then you must use the option --no-symbols (or -s). To exclude numbers the option --no-numbers or short-hand -n must be used. And finally to exclude lowercase characters use --no-lowercase (or -l) and to exclude uppercase characters use --no-uppercase (or -u).

To support a requirement that at least one character, one number and one symbol is needed the option --require-each-type must be used. By default Nushell will not use the ambiguous characters 0, O, 1 and l in the same password, because it can be hard to read the differences between the characters with some fonts. In order to use these characters in the same generated password you must the option --include-ambiguous. Also the characters i, 1 and l are not used together, but if you specify the option --include-similar these characters can be used in the same generated password.

April 19, 2026

Nushell Niceties: Wrapping External Commands With def --wrapped

The def keyword in Nushell is used to define a custom command. By adding the --wrapped flag you can tell Nushell to accept unknown flags and arguments and pass them on as strings. In the command parameters you use a "rest" parameter defined by …​ to capture the remaining arguments. Then in the command body you use the spread operator …​ to expand them again. This is very useful when you want to create a small wrapper around an external command with lots of options, but without having to define all those options yourself.

March 20, 2026

Nushell Niceties: Sorting Version Values With Semver Ordering

The semver Nushell plugin can be used to work with string values as semver type as you can see in a previous post. You can use the semver sort command to sort string values with ordering rules for semantic versions. With natural ordering of string values a value of 10.0.1 is placed before 2.1.0, but if you use semver sort the ordering will be correct. The command will look at all the parts of the semver type. So a major version of 2 is placed before 10. If the major version part is the same than the minor part is used for ordering and so on. To sort in descending order you can use the option --reverse or the short option -r.

February 17, 2026

Nushell Niceties: Transform Values Into Semver Types

Nushell can be extended with plugins to have more functionality or types that are not part of standard Nushell. If you want to work with string values that are actually semantic version values (https://semver.org) you can use the Nushell SemVer plugin. The plugin must be added to Nushell by using the command plugin add <location of plugin>. You can check with plugin list command if the plugin is available. This command also shows commands that the plugin adds to Nushell.

The command into semver can be used to convert string values into a semver type. The semver type has 5 properties: major, minor, patch, pre and build. You can use dot notation to get the values for these properties or use the get command. In the following command a string value is transformed to a semver type: let v = '4.0.2' | into semver. And with $v.major you can extract the major part of the semver value and it returns 4.
Records with the keys major, minor, patch, pre and build can be transformed to a semver string with the semver from-record command. And to transform a semver type to a record you can use the command semver into-record.