When you start Nushell you can see a nice ASCII art elephant. That is Ellie a cute and friendly elephant mascot for Nushell. Elephants are popular as you can see them in other products like Mastodon and Gradle. It is possible to summon Ellie in your Nushell environment by running the ellie command. This command is part of the std library and you need to run use std ellie or std use * first.
Continue reading →
To get the names of columns in a table or the keys of a record you can use the columns command. The command returns a list of string values that are the column or key names. When the input is table the column names are returned, and when the input is a record the names of the keys are returned.
Continue reading →
The build-in HTTP client in Nushell can be used to interact with REST APIs and websites. If the URL you want to invoke has query parameters than you can use the url build-query command. The url build-query command transforms a record or table to URL encoded key/value pairs joined with an ampersand (&). Each key and value is separated by an equal sign (=). The command can expand a key with a list value to separate key/value pairs with the same key if the key is defined in a record.
Continue reading →
The string module contains a lot of useful commands to work with strings. If you want to join several values from a list into a single string you can use the str join command. The command accepts as argument the character(s) to use for joining the values. If you don’t specify the character(s) as argument the default value '' (empty string) is used.
Continue reading →
Sometimes you want to transform a string value into a URL encoded value, so it can be used as part of a valid URL. For example a string with spaces or special characters can not be used in a URL as is, but needs to be URL encoded. Nushell has the url encode command to achieve this. You can simple run this command on a string value and the result is a URL encoded value. With the option --all or -a even more special characters like a dot (.) are encoded. The input of the command can be a string value or a list of string values. But it is also possible to use a record or table structure, but then you need to add as extra argument the name or names of the keys or columns of which the string values should be encoded.
Oppossed to URL encoding a value you can also decode a URL encoded value using the url decode command. This command doesn’t have a special option to run. Just like with the url encode command the url decode command works on strings, list of strings, records and tables. If the input is a record or table the name of key or column of which the values must be decoded must be passed as extra arguments.
Continue reading →
The Nushell command enumerate adds an index value to each item in a list. The index value is stored in an extra column named index. You can use this column to filter data based on the index value.
Continue reading →
Nushell has very useful commands to filter lists and tables. When you have a list with null values, you can use the compact command to filter out the null values. With the option --empty you can also filter out empty items like empty strings, empty lists and empty records. If you want to filter out rows in a table where a column contains a null value, you can use the compact command followed by the name of the column.
Continue reading →
Nushell has some nice built-in commands to get randomized data. The random command can be used to get random numbers, strings, and more. You can use the dice subcommand to get random numbers between 1 and 6. The command returns a list of integers. With the option --dice you can specify how many times to throw the dice. By default the dice has 6 sides, but you can use the option --sides to change that. You could roll a dice with 2 sides, like flipping a coin, or roll a dice with 10 sides.
Continue reading →
The nice thing about the http command in Nushell is that you can interact with HTTP endpoints without the need to install any external tools. You can use several subcommands like get, post, put, delete and patch. Each of these commands has the options to specify request headers. You can use the option --headers or the short version -H followed by a list of header keys and values.
Continue reading →
The http command in Nushell can be used to interact with HTTP endpoints. You can post data to an endpoint using the post subcommand. If you want to post JSON data than you can simply use a record data structure and use the argument --content-type application/json (or the shorthand -t application/json). Nushell will automatically convert the record data structure to JSON and use it as the body of the HTTP request.
Continue reading →
Nushell has a built-in command to invoke HTTP requests: http. You don’t need an external tool like curl or httpie to make HTTP requests. There a lot of options to use with the http command. One of them is the --full or shorter -f option to return a table with extra details of the HTTP request and response. The request and response headers, the body and status are returned in the table. You can easily get information from the table with all the default selection options for a table structure.
Continue reading →
Nushell has a lot of commands to work with strings. The str kebab-case command can be used to convert a string to kebab case. Kebab-case is a string that contains only lowercase letters and words are separated by hyphens.
Continue reading →