Search

Dark theme | Light theme

September 12, 2026

Nushell Niceties: Write XML With Comments

You can learn about writing XML with Nushell n a previous blogpost. To add a XML comment you can use a record with the key tag and string value !. The content key should be a string value that is the actual comment. The result after you use the to xml is a XML text that has the format of a XML comment: <!-- <content> -→.

Nushell Niceties: Writing XML

In Nushell almost everything is a data structure. This mind set is also applied to XML structures in Nushell. A XML tag can be described as a record with the attributes tag, attributes and content. The tag attribute has a string value that is the tag name. Attributes are defined with a record structure. The key is the attribute name and the value is the attribute value. Finally the content attribute is a list containing a string value for text content or new record structures for nested XML tags. With this basic record structure you can describe XML content. To actually transform it to a XML string value you can use the command to xml. This command will use the data in the record structure and will output XML.

September 2, 2026

Nushell Niceties: Split String By Words

To split a string value by the words in the string you can use the command split words. The result is a list where each element is a word from the original string. You can use the option --min-word-length (or the short option -l) to specify a minimal length of the words that should be split on. When a word length is less than the given option value it will not be in the resulting list.

July 28, 2026

Nushell Niceties: Splitting String Values Into A Table

You can use the split column command to split a string value or a list of string values into a table. You need to specify a delimiter to split the value on. In the resulting table the elements are stored in columns. By default the columns have the name column<index> where index is the number of the column starting with 0. It is possible to define your own column names by specifying their names as parameters for the split column command. This way the resulting table will have more meaningful names.

July 19, 2026

Nushell Niceties: Finding Same Elements In Lists Or Tables

The intersect command can be used on lists and tables to find the same elements that are in the input list or table and a provided list or table. The input is passed to the command and the other list or table is an argument for the intersect command.

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.

April 4, 2026

Kotlin Kandy: Get Text Before Or After A Delimiter

Kotlin adds the substringBefore, substringBeforeLast, substringAfter and substringAfterLast extension functions to the String class. Instead of using indices to get a substring you can use a string or character value. The functions without Last use the first occurrence of the delimiter and the methods with Last use the last occurrence. If the delimiter is not found the original string is returned. You can supply a value that should be returned when the delimiter is not found.

April 3, 2026

Kotlin Kandy: Get A Random Element From A Collection

Kotlin has very useful extensions functions for working with collections. These extension functions make working with collections more easy and fun. One of the extension functions is the random function. When you call random() Kotlin returns a single element from the collection using the default random source. The function also accepts a Random instance as argument. This instance has a seeded value to return repeatable random values.

April 2, 2026

Kotlin Kandy: Transform Map Keys Or Values With mapKeys And mapValues

Sometimes you want to transform only the keys in a Map, or only transform the values. Kotlin has two useful methods to achieve this: mapKeys and mapValues. You can use mapKeys to transform the keys of the map while keeping the values the same. With mapValues you can transform the values of the map while keeping the keys the same. Both methods accept a lambda function as asrgument of type Map.Entry and must return the new key or value. In order to transform the keys or values and add the result to an existing Map you can use the methods mapKeysTo and mapValuesTo. The first argument is the existing (mutable) Map and the second argument is the lambda function.