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.
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.
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.
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.
With the command config nu
you can change the Nushell configuration. In order to enable any changes you made in the current shell session you must run source $nu.config-path
. This will load the configuration in the current shell session. Another option is of course to stop the current shell session and start a new one.
Written with Nushell 0.104.0.
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.
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.
To look at the contents of a file you can use the open
command in Nushell.
But if we want to open a file with an associated application you must use the start
command.
For example if you have an HTML file and use the open
command you see the HTML source.
When you use the start
command it opens the HTML file in your default browser.
You can also use the start
command to open a directory in the file manager of your operating system.
If you use MacOS and type start .
it will open the current directory in the Finder application.
When you use the start
command followed by a URL it will open the URL in your default browser.
Written with Nushell 0.103.0.
SDKMAN! is as powerful tool to install and manage software development kits (SDKs) and tools, like Java, Groovy, Gradle, Maven, Spring Boot and Quarkus.
If you want to see if a new version of a SDK or tool is available, you can use the sdk upgrade
command.
This command will list all outdated SDKs and tools.
The installed version and the latest version are shown for each SDK and tool.
To see if a single SDK or tool is outdated, you can use the name of the SDK or tool as argument to the sdk upgrade
command.
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.
Nushell has some powerful commands to work with strings.
The str trim
command can be used to trim whitespace from a string.
By default whitespace from the beginning and end of a string is removed.
To only remove whitespace from the beginning of the string you can use the --left
argument (or the shorter option -l
).
For removing whitespace from the end of the string you can use the option --right
or the shorter option -r
.
To trim a string based on another character you can use the option --char
or the shorter option -c
followed by the character to trim.