├── book.json ├── es ├── book.json ├── escapando.md ├── README.md ├── plugins.md ├── LICENSE ├── metadatos.md ├── pipeline.md ├── tipos_de_datos.md ├── explorando.md ├── instalacion.md ├── cargando_datos.md ├── shells_en_shells.md ├── introduccion.md └── trabajando_con_tablas.md ├── README.md ├── en ├── escaping.md ├── README.md ├── plugins.md ├── metadata.md ├── types_of_data.md ├── pipeline.md ├── moving_around.md ├── installation.md ├── loading_data.md ├── shells_in_shells.md ├── introduction.md └── working_with_tables.md ├── LICENSE └── SUMMARY.md /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "structure": { 3 | "readme": "es/installation.md" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /es/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "structure": { 3 | "readme": "instalacion.md" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Nu book 2 | 3 | The work-in-progress book for nushell. You can via it live at [book.nushell.sh](https://book.nushell.sh) 4 | 5 | Please see the directory for each language for a full list of available chapters. 6 | -------------------------------------------------------------------------------- /en/escaping.md: -------------------------------------------------------------------------------- 1 | # Escaping to the system 2 | 3 | Nu provides a set of commands that you can use across different OSes, and having this consistency is helpful. Sometimes, though, you want to run a command that has the same name as Nu commands. To run the local `ls` or `date` command, for example, you use the caret (^) command. 4 | 5 | Nu command: 6 | 7 | ``` 8 | > ls 9 | ``` 10 | 11 | Escape to local command: 12 | 13 | ``` 14 | > ^ls 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /es/escapando.md: -------------------------------------------------------------------------------- 1 | # Escapando al sistema 2 | 3 | Nu proporciona una serie de comandos que puedes utilitar en diferentes sistemas operativos y tener esta consistencia es de gran ayuda. Sin embargo, a veces, quieres ejecutar un comando que también tiene el mismo nombre de los comandos de Nu. Para ejecutar el comando local `ls` o `date` fuera de Nu por ejemplo, usa el comando de intercalación (^). 4 | 5 | Comando de Nu: 6 | 7 | ``` 8 | > ls 9 | ``` 10 | 11 | Escapa al comando local: 12 | 13 | ``` 14 | > ^ls 15 | ``` -------------------------------------------------------------------------------- /en/README.md: -------------------------------------------------------------------------------- 1 | # The Nu book 2 | The work-in-progress book for nushell 3 | 4 | Currently available are: 5 | 6 | * [Installation](installation.md) - Installing nushell 7 | * [Introduction](introduction.md) - Getting started 8 | * [Moving around](moving_around.md) - Moving around in nushell 9 | * [Types of data](types_of_data.md) - Types of data in nushell 10 | * [Loading data](loading_data.md) - Loading data and using it 11 | * [Working with tables](working_with_tables.md) - Working with nushell tables 12 | * [Pipeline](pipeline.md) - How the pipeline works 13 | * [Metadata](metadata.md) - An explanation of nushell's metadata system 14 | * [Shells](shells_in_shells.md) - Working with multiple locations 15 | * [Escaping commands](escaping.md) - Escaping to native commands of the same name 16 | * [Plugins](plugins.md) - Enhancing nushell with more features using plugins 17 | 18 | -------------------------------------------------------------------------------- /en/plugins.md: -------------------------------------------------------------------------------- 1 | # Plugins 2 | 3 | The functionality of Nu can be extended using plugins. The plugins can perform many of the same operations that Nu's built-in commands can, with the added benefit that they can be added separately of Nu itself. 4 | 5 | To add a plugin, simply build it and put the binary in your PATH. Nu plugins begin with the filename `nu_plugin_` so that Nu can find them among other binaries in your PATH. 6 | 7 | **Note:** in the future, plugins may have a specific place they need to be put in order for Nu to find them. 8 | 9 | When Nu starts up, it scans your system and loads the plugins it finds. 10 | 11 | The protocol that Nu plugins use is subject to change while Nu is under heavy development. The best place to learn more about the protocol and how to create your own plugins is by reading the source for the [plugins in the Nu repository](https://github.com/nushell/nushell/tree/master/src/plugins). 12 | -------------------------------------------------------------------------------- /es/README.md: -------------------------------------------------------------------------------- 1 | # El libro Nu. Puedes ver un demo en vivo aquí [book.nushell.sh](https://book.nushell.sh) 2 | 3 | El libro (en progreso) de nushell 4 | 5 | Actualmente disponible hay: 6 | 7 | * [Instalación](instalacion.md) - Instalando nushell 8 | * [Introducción](introduccion.md) - Empezando 9 | * [Explorando](explorando.md) - Explorando en nushell 10 | * [Tipos de datos](tipos_de_datos.md) - Tipos de datos en nushell 11 | * [Cargando datos](cargando_datos.md) - Cargando datos y usándola 12 | * [Trabajando con tablas](trabajando_con_tablas.md) - Trabajando con tablas nushell 13 | * [Pipeline](pipeline.md) - Cómo funciona el pipeline 14 | * [Metadatos](metadatos.md) - Una explicación del sistema de metadatos en nushell 15 | * [Shells](shells_en_shells.md) - Trabajando con múltiples ubicaciones 16 | * [Escapando commandos](escapando.md) - Escapando a comandos nativos de mismo nombre 17 | * [Plugins](plugins.md) - Mejorando nushell con más funcionalidades usando complementos 18 | -------------------------------------------------------------------------------- /es/plugins.md: -------------------------------------------------------------------------------- 1 | # Complementos (plugins) 2 | 3 | Se puede ampliar la funcionalidad de Nu a través de complementos. Los complementos pueden realizar muchas de las mismas operaciones que los comandos integrados de Nu con el beneficio adicional de que se pueden agregar separado de Nu. 4 | 5 | Para agregar un complemento simplemente compílalo y colóca el binario en el PATH. Los complementos de Nu empiezan con `nu_plugin_` de manera que Nu pueda encontrarlos entre otros binarios en su PATH. 6 | 7 | **Nota:** en el futuro los complementos pueden que tengan un lugar específico que deban ser puestos para Nu encontrarlos. 8 | 9 | Cuándo Nu arranca escanea el sistema y carga los complementos que encuentre. 10 | 11 | El protocolo que usan los complementos de Nu está sujetos a cambios mientras Nu está bajo fuerte desarrollo. El mejor lugar para aprender más sobre el protocolo y cómo crear tus propios complementos es leyendo el código fuente de los [complementos en el repositorio de Nu](https://github.com/nushell/nushell/tree/master/src/plugins). 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 nushell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /es/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 nushell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | * [English](en/README.md) 2 | * [Installation](en/installation.md) - Installing nushell 3 | * [Introduction](en/introduction.md) - Getting started 4 | * [Moving around](en/moving_around.md) - Moving around in nushell 5 | * [Types of data](en/types_of_data.md) - Types of data in nushell 6 | * [Loading data](en/loading_data.md) - Loading data and using it 7 | * [Working with tables](en/working_with_tables.md) - Working with nushell tables 8 | * [Pipeline](en/pipeline.md) - How the pipeline works 9 | * [Metadata](en/metadata.md) - An explanation of nushell's metadata system 10 | * [Shells](en/shells_in_shells.md) - Working with multiple locations 11 | * [Escaping commands](en/escaping.md) - Escaping to native commands of the same name 12 | * [Plugins](en/plugins.md) - Enhancing nushell with more features using plugins 13 | * [Español](es/README.md) 14 | * [Instalación](es/instalacion.md) - Instalando nushell 15 | * [Introducción](es/introduccion.md) - Empezando 16 | * [Explorando](es/explorando.md) - Explorando en nushell 17 | * [Tipos de datos](es/tipos_de_datos.md) - Tipos de datos en nushell 18 | * [Cargando datos](es/cargando_datos.md) - Cargando datos y usándola 19 | * [Trabajando con tablas](es/trabajando_con_tablas.md) - Trabajando con tablas nushell 20 | * [Pipeline](es/pipeline.md) - Cómo funciona el pipeline 21 | * [Metadatos](es/metadatos.md) - Una explicación del sistema de metadatos en nushell 22 | * [Shells en shells](es/shells_en_shells.md) - Trabajando con múltiples ubicaciones 23 | * [Escapando](es/escapando.md) - Escapando a comandos nativos de mismo nombre 24 | * [Plugins](es/plugins.md) - Mejorando nushell con más funcionalidades usando complementos 25 | -------------------------------------------------------------------------------- /en/metadata.md: -------------------------------------------------------------------------------- 1 | # Metadata 2 | 3 | In using Nu, you may have come across times where you felt like there was something extra going on behind the scenes. For example, let's say that you try to open a file that Nu supports only to forget and try to convert again: 4 | 5 | ``` 6 | > open Cargo.toml | from-toml 7 | error: Expected a string from pipeline 8 | - shell:1:18 9 | 1 | open Cargo.toml | from-toml 10 | | ^^^^^^^^^ requires string input 11 | - shell:1:5 12 | 1 | open Cargo.toml | from-toml 13 | | ---------- object originates from here 14 | ``` 15 | 16 | The error message tells us not only that what we gave `from-toml` wasn't a string, but also where the value originally came from. How would it know that? 17 | 18 | Values that flow through a pipeline in Nu often have a set of addition information, or metadata, attached to them. These are known as tags, like the tags on an item in a store. These tags don't affect the data, but they give Nu a way to improve the experience of working with that data. 19 | 20 | Let's run the `open` command again, but this time, we'll look at the tags it gives back: 21 | 22 | ``` 23 | > open Cargo.toml | tags 24 | ----------+------------------------------------------ 25 | span | origin 26 | ----------+------------------------------------------ 27 | [object] | /home/jonathan/Source/nushell/Cargo.toml 28 | ----------+------------------------------------------ 29 | ``` 30 | 31 | Currently, we track two bits of metadata on the values in pipeline. You can notice that we have the origin, which gives the location for where this data was loaded from. This can help Nu better understand how to present data. 32 | 33 | There's also a span. Let's take a closer look at that: 34 | 35 | ``` 36 | > open Cargo.toml | tags | get span 37 | -------+----- 38 | start | end 39 | -------+----- 40 | 5 | 15 41 | -------+----- 42 | ``` 43 | 44 | The span "start" and "end" here refer to where the underline will be in the line. If you count over 5, and then count up to 15, you'll see it lines up with the "Cargo.toml" filename. This is how the error we saw earlier knew what to underline. 45 | 46 | 47 | -------------------------------------------------------------------------------- /es/metadatos.md: -------------------------------------------------------------------------------- 1 | # Metadatos 2 | 3 | Al usar Nu es posible que hayan momentos que has encontrado como si algo extra sucediera detrás de escenas. Por ejemplo digamos que intentas abrir un archivo soportado por Nu para luego olvidarte e intentar convertir nuevamente: 4 | 5 | ``` 6 | > open Cargo.toml | from-toml 7 | error: Expected a string from pipeline 8 | - shell:1:18 9 | 1 | open Cargo.toml | from-toml 10 | | ^^^^^^^^^ requires string input 11 | - shell:1:5 12 | 1 | open Cargo.toml | from-toml 13 | | ---------- object originates from here 14 | ``` 15 | 16 | El mensaje de error nos indica que hemos proporcionado a `from-toml` algo distinto a una cadena pero también el origen del valor. ¿Cómo puede saberlo? 17 | 18 | Valores que fluyen a través de la tubería en Nu comúnmente disponen de información adicional (o metadatos) adjuntadas en las mismas. Se conocen como etiquetas como las etiquetas en una tienda. Estas etiquetas no afecta los datos pero permiten a Nu mejorar la experiencia mientras se trabaja con esos datos. 19 | 20 | Nuevamente ejecutemos el comando `open` pero esta vez observaremos las etiquetas que nos devuelve: 21 | 22 | ``` 23 | > open Cargo.toml | tags 24 | ----------+------------------------------------------ 25 | span | origin 26 | ----------+------------------------------------------ 27 | [object] | /home/jonathan/Source/nushell/Cargo.toml 28 | ----------+------------------------------------------ 29 | ``` 30 | 31 | Actualmente rastreamos dos pedazos de metadatos de los valores en la tubería. Puedes darte cuenta que disponemos del origen que nos da la ubicación de dónde se cargaron los datos. Esto puede ayudar a Nu entender mejor como presentar datos. 32 | 33 | También hay lapso (span). Miremos más de cerca a eso: 34 | 35 | ``` 36 | > open Cargo.toml | tags | get span 37 | -------+----- 38 | start | end 39 | -------+----- 40 | 5 | 15 41 | -------+----- 42 | ``` 43 | 44 | El lapso "start" y "end" aquí se refiere en dónde estará el subrayado en la línea. Si cuentas a partir de 5 y luego hasta 15 podrás observar que se alinea con el nombre de archivo "Cargo.toml". Así es como Nu sabía qué subrayar apropiadamente en el error que vimos previamente. 45 | 46 | 47 | -------------------------------------------------------------------------------- /en/types_of_data.md: -------------------------------------------------------------------------------- 1 | # Types of data 2 | 3 | Traditionally, Unix shell commands have communicated with each others using strings of text. One command would output text via standard out (often abbreviated 'stdout') and the other would read in text via standard in (or 'stdin'). In this way, the two commands could communicate. 4 | 5 | We can think of this kind of communication as string-based. 6 | 7 | Nu embraces this approach for its commands and grows it to include other kinds of data. Currently, Nu supports two kinds of data types: simple and structured. 8 | 9 | ## Simple data 10 | 11 | Like many programming languages, Nu models data using a set of simple and structured data types. Simple data types include integers, floats, strings, booleans, dates, and paths. It also includes a special type for filesizes. 12 | 13 | ### Integers 14 | 15 | Integers (or round) numbers. Examples include 1, 5, and 100. 16 | 17 | ### Floats 18 | 19 | Floating point numbers are numbers with some fractional component. Examples include 1.5, 2.0, and 15.333. 20 | 21 | ### Strings 22 | 23 | Strings are the fundamental way of representing text. They are quoted using double quotes. Examples include "Fred", "myname.txt", and "Lynchburg, VA". 24 | 25 | Strings in Nu are Unicode aware by default, so you can pass UTF-8 text with ease. 26 | 27 | ### Booleans 28 | 29 | Booleans are the state of being true or false. Rather than writing the value directly, it is often a result of a comparison. 30 | 31 | ### Dates 32 | 33 | Dates and times are held together in the Date value type. Date values used by the system are timezone-aware, and by default use the UTC timezone. 34 | 35 | ### Paths 36 | 37 | Paths are a platform-independent way of representing a filepath in the given OS. Examples include /usr/bin and C:\Users\file.txt. 38 | 39 | ### Bytes 40 | 41 | Filesizes are held in a special integer type called bytes. Examples include 100, 15kb, and 100mb. 42 | 43 | ## Structured data 44 | 45 | Structured data builds from the simple data. For example, instead of a single integer, structured data gives us a way to represent multiple integers in the same value. Here's a list of the currently supported structured data types: objects, binary data, lists, and blocks. 46 | 47 | ### Objects 48 | 49 | The object data type represents what you would see in one row of data in the table. It has different elements of data, and each element of data is given a column name. 50 | 51 | ### Binary data 52 | 53 | Binary data, like the data from an image file, is a group of raw bytes. 54 | 55 | ### Lists 56 | 57 | Lists can hold more than one value. This allows them to be a good container for rows of data in a table. 58 | 59 | ### Blocks 60 | 61 | Blocks represent a block of code in Nu. For example, in the command `where { $it.size > 10kb }` the block is the portion contained in curly braces, `{ $it.size > 10kb }`. Blocks are a useful way of representing code that can be executed on each row of data. 62 | 63 | -------------------------------------------------------------------------------- /en/pipeline.md: -------------------------------------------------------------------------------- 1 | # The pipeline 2 | 3 | One of the core designs of Nu is the pipeline, a design idea that tracks its roots back decades to some of the original philosophy behind Unix. Just as Nu extends from the single string data type of Unix, Nu also extends the idea of the pipeline to include more than just text. 4 | 5 | ## Basics 6 | 7 | A pipeline is constructed with three parts: the input, the filter, and the output. 8 | 9 | ``` 10 | > open "Cargo.toml" | inc package.version | save "Cargo_new.toml" 11 | ``` 12 | 13 | The first command, `open "Cargo.toml"`, is an input (sometimes also called a "source" or "producer"). This creates or loads data and feeds it into a pipeline. It's from input that pipelines have values to work with. Commands like `ls` are also inputs, as they take data from the filesystem and send it through the pipelines so that it can be used. 14 | 15 | The second command, `inc package.version`, is a filter. Filters take the data they are given and often do something with it. They may change it (as with the `inc` command in our example), or they may do another operation, like logging, as the values pass through. 16 | 17 | The last command, `save "Cargo_new.toml"`, is an output (sometimes called a "sink"). An output takes input from the pipeline and does some final operation on it. In our example, we save what comes through the pipeline to a file as the final step. Other types of output commands may take the values and view them for the user. 18 | 19 | ## Working with external commands 20 | 21 | Nu commands communicate with each other using the Nu data types (see [types of data](types_of_data.md)), but what about commands outside of Nu? Let's look at some examples of working with external commands: 22 | 23 | `internal_command | external_command` 24 | 25 | Data will flow from the internal_command to the external_command. This data is expected to be strings, so that they can be sent to the `stdin` of the external_command. 26 | 27 | `external_command | internal_command` 28 | 29 | Data coming from an external command into Nu will collect into a single string, and then will be passed into internal_command. Commands like `lines` help make it easier to bring in data from external commands in such a way that it's easier to work with. 30 | 31 | `external_command_1 | external_command_2` 32 | 33 | Nu works with data piped between two external commands in the same way other shells, like Bash would. The `stdout` of external_command_1 is connected to the `stdin` of external_command_2. This lets data flow naturally between the two commands. 34 | 35 | ## Behind the scenes 36 | 37 | You may have wondered how we see a table if `ls` is an input and not an output. Nu adds this output for us automatically using another command called `autoview`. The `autoview` command is appended to any pipeline that doesn't have an output allowing us to see the result. 38 | 39 | In effect, the command: 40 | 41 | ``` 42 | > ls 43 | ``` 44 | 45 | And the pipeline: 46 | 47 | ``` 48 | > ls | autoview 49 | ``` 50 | 51 | Are one and the same. 52 | -------------------------------------------------------------------------------- /es/pipeline.md: -------------------------------------------------------------------------------- 1 | # El pipeline 2 | 3 | Uno de los diseños centrales de Nu es la tubería (pipeline), una idea de diseño que rastrea sus raíces décadas atrás hasta parte de la filosofía original detrás de Unix. Así como Nu extiende desde un solo dato tipo de cadena de Unix, Nu también extiende la idea de tuberías (pipelines) para incluir más que solo texto. 4 | 5 | ## Fundamentos 6 | 7 | Una tubería (pipeline) es construída con tres partes: la entrada, el filtro, y la salida. 8 | 9 | ``` 10 | > open "Cargo.toml" | inc package.version | save "Cargo_new.toml" 11 | ``` 12 | 13 | El primer comando, `open "Cargo.toml"`, es una entrada (a veces también llamada "fuente" o "productor"). Esto crea o carga datos y lo canaliza en la tubería. Es de entrada para la tubería tener valores y poder trabajarlas. Comandos como `ls` también son entradas ya que toman datos desde el sistema de archivos y lo canalizan a través de las tuberías para que puedan ser usadas. 14 | 15 | El segundo comando, `inc package.version`, es un filtro. Filtros toman los datos que se les entrega y comúnmente hacen algo con la misma. Puede que la cambien (tal como el comando `inc` en nuestro ejemplo), o pueden hacer otra operación, como registrar, mientras pasan los valores. 16 | 17 | El último comando, `save "Cargo_new.toml"`, es una salida (a veces llamado un "sink"). Una salida toma la entrada de la tubería y realiza alguna operación final. En nuestro ejemplo, grabamos lo que viene a través de la tubería hacia un archivo como paso final. Otros tipos de comandos de salida pueda que tomen valores y lo muestren para el usuario. 18 | 19 | ## Trabajando con comandos externos 20 | 21 | Los comandos en Nu se comunican entre ellos usando los tipos de datos de Nu (mirar [tipos de datos](tipos_de_datos.md)) pero, ¿qué hay de comandos fuera de Nu? Miremos algunos ejemplos trabajando con comandos externos: 22 | 23 | `commando_interno | comando_externo` 24 | 25 | Los datos fluirán desde comando_interno al comando_externo. Estos datos se esperan que sean cadenas para que puedan ser enviadas a entrada estándar `stdin` del comando_externo. 26 | 27 | `comando_externo | comando_interno` 28 | 29 | Los datos que vienen de un comando externo a Nu se coleccionará a una sola cadena y luego serán pasadas a comando_interno. Comandos como `lines` ayudan a facilitar datos provenientes de comandos externos de manera que sea más facil trabajarlas. 30 | 31 | `comando_externo_1 | comando_externo_2` 32 | 33 | Nu trabaja con datos canalizados entre dos comandos externos de la misma forma como en otras shells, como Bash lo haría. La salida estándar `stdout` de comando_externo_1 es conectada a la entrada estándar `stdin` de comando_externo_2. Esto permite que los datos fluyan naturalmente entre dos comandos. 34 | 35 | ## Detrás de escenas 36 | 37 | Es posible que te hayas preguntado como miramos una tabla si `ls` es una entrada y no una salida. Nu agrega esta salida por nosotros automáticamente usando otro comando llamado `autoview`. El comando `autoview` es añadido a cualquier tubería que no tenga una salida permitiéndonos ver el resultado. 38 | 39 | En efecto, el comando: 40 | 41 | ``` 42 | > ls 43 | ``` 44 | 45 | y la tubería: 46 | 47 | ``` 48 | > ls | autoview 49 | ``` 50 | 51 | Son uno y lo mismo. 52 | 53 | -------------------------------------------------------------------------------- /es/tipos_de_datos.md: -------------------------------------------------------------------------------- 1 | # Tipos de datos 2 | 3 | Tradicionalmente, comandos shell de Unix se han comunidado entre ellos usando cadenas de texto. Un comando generaría de salida texto a través de la salida estándar (comúnmente abreviada 'stdout') y el otro leer texto a través de la entrada estándar (o 'stdin'). 4 | 5 | Podemos pensar de este tipo de comunicación como basada en cadenas. 6 | 7 | Nu adopta este enfoque para sus comandos y lo hacer crecer para incluir otro tipos de datos. Actualmente, Nu incluye soporte para dos tipos de datos: simple y estructurada. 8 | 9 | ## Datos simples 10 | 11 | Al igual que muchos lenguajes de programación, Nu modela los datos usando un conjunto de tipos de datos simples y estructurados. Tipos de dato simple incluye enteros, decimales, cadenas, booleanos, fechas, y rutas. También incluye un tipo especial para tamaños de archivos. 12 | 13 | ### Enteros 14 | 15 | Enteros (o redondos). Ejemplos incluye 1, 5, y 100. 16 | 17 | ### Decimales 18 | 19 | Números decimales son números con algún component fraccional. Ejemplos incluye 1.5, 2.0, y 15.333. 20 | 21 | ### Cadenas 22 | 23 | Las cadenas son la manera fundamental de representar texto. Se indican con doble comillas. Ejemplos incluye "Pedro", "minombre.txt", and "Lynchburg, VA". 24 | 25 | Cadenas en Nu son compatibles con Unicode de manera predeterminada, por lo que puedes pasar texto UTF-8 con facilidad. 26 | 27 | ### Booleanos 28 | 29 | Booleanos son el estado de verdadero o falso. En vez de escribir el valor directamente, comúnmente es el resultado de una comparación. 30 | 31 | ### Fechas 32 | 33 | Fechas y horas se mantienen juntas en el valor tipo de dato Date. Valores Date usados por el sistema reconocen la zona horaria y de manera predeterminada usa la zona horaria UTC. 34 | 35 | ### Rutas 36 | 37 | Las rutas son una forma independiente de la plataforma para representar rutas de archivos en el sistema operativo dado. Ejemplos incluyen: /usr/bin y C:\Users\archivo.txt. 38 | 39 | ### Bytes 40 | 41 | Tamaños de archivos se mantienen dentro de un tipo especial de entero llamado bytes. Ejemplos incluye 100, 15kb, y 100mb. 42 | 43 | ## Datos estructurados 44 | 45 | Los datos estructurados se construyen a partir de los datos simples. Por ejemplo, en lugar de un solo entero, datos estructurados nos ofrece una manera de representar múltiples enteros en el mismo valor. Esta es una lista actual de los tipos de dato estructurados soportadas: objetos, datos binarios, listas, y bloques. 46 | 47 | ### Objetos 48 | 49 | El tipo de dato object representa lo que observarías en una fila de datos de una tabla. Tiene diferentes elementos de datos y cada elemento de dato se le asigna un nombre de columna. 50 | 51 | ### Datos binarios 52 | 53 | Datos binarios como los datos de un archivo de imagen, es un grupo de bytes sin formato. 54 | 55 | ### Listas 56 | 57 | Las listas pueden tener más de un valor. Esto les permite ser un buen contenedor de filas de datos de una tabla. 58 | 59 | ### Bloques 60 | 61 | Bloques representan bloques de código en Nu. Por ejemplo, en el comando `where { $it.size > 10kb }` el bloque es la porción contenida en las llaves, `{ $it.size > 10kb }`. Los bloques son una manera útil de representar código que puede ser ejecutado para cada fila de datos. -------------------------------------------------------------------------------- /en/moving_around.md: -------------------------------------------------------------------------------- 1 | # Moving around your system 2 | 3 | Early shells allow you to move around your filesystem and run commands, and modern shells like Nu allow you to do the same. Let's take a look at some of the common commands you might use when interacting with your system. 4 | 5 | ## Viewing directory contents 6 | 7 | ``` 8 | > ls 9 | ``` 10 | 11 | As we've seen in other chapters, `ls` is a command for viewing the contents of a path. Nu will return the contents as a table that we can use. 12 | 13 | The `ls` command also takes an optional argument, to change what you'd like to view. For example, we can list the files that end in ".txt" 14 | 15 | ``` 16 | > ls *.txt 17 | ---+--------------+------+----------+---------+--------------+-------------- 18 | # | name | type | readonly | size | accessed | modified 19 | ---+--------------+------+----------+---------+--------------+-------------- 20 | 0 | history.txt | File | | 1.3 KB | 2 months ago | a day ago 21 | 1 | readonly.txt | File | readonly | | 2 months ago | 2 months ago 22 | ---+--------------+------+----------+---------+--------------+-------------- 23 | ``` 24 | 25 | The asterisk (\*) in the above optional argument "\*.txt" is sometimes called a wildcard or a glob. It lets us match anything. You could read the glob "\*.txt" as "match any filename, so long as it ends with '.txt' " 26 | 27 | Nu also uses modern globs as well, which allow you access to deeper directories. 28 | 29 | ``` 30 | > ls **/*.rs 31 | -----+-----------------------------------------------------+------+----------+----------+----------------+---------------- 32 | # | name | type | readonly | size | accessed | modified 33 | -----+-----------------------------------------------------+------+----------+----------+----------------+---------------- 34 | 0 | src/cli.rs | File | | 19.1 KB | 15 hours ago | 15 hours ago 35 | 1 | src/commands/args.rs | File | | 244 B | 2 months ago | 2 months ago 36 | 2 | src/commands/autoview.rs | File | | 2.5 KB | 15 hours ago | 15 hours ago 37 | 3 | src/commands/cd.rs | File | | 277 B | a week ago | a week ago 38 | 4 | src/commands/classified.rs | File | | 13.5 KB | 15 hours ago | 15 hours ago 39 | 5 | src/commands/clip.rs | File | | 2.0 KB | 2 days ago | 2 days ago 40 | ``` 41 | 42 | Here we're looking for any file that ends with ".rs", and the two asterisks further say "in any directory starting from here". 43 | 44 | ## Changing the current directory 45 | 46 | ``` 47 | > cd new_directory 48 | ``` 49 | 50 | To change from the current directory to a new one, we use the `cd` command. Just as in other shells, we can use either the name of the directory, or if we want to go up a directory we can use the `..` shortcut. 51 | 52 | ## Filesystem commands 53 | 54 | Nu also provides some basic filesystem commands that works crossplatform. 55 | 56 | We can move an item from one place to another using the `mv` command: 57 | 58 | ``` 59 | > mv item location 60 | ``` 61 | 62 | We can copy an item from one location to another: 63 | 64 | ``` 65 | > cp item location 66 | ``` 67 | 68 | We can remove an item: 69 | 70 | ``` 71 | > rm item 72 | ``` 73 | 74 | The three commands also can use the glob capabilities we saw earlier with `ls`. 75 | 76 | Finally, we can create a new directory using the `mkdir` command: 77 | 78 | ``` 79 | > mkdir new_directory 80 | ``` 81 | 82 | -------------------------------------------------------------------------------- /es/explorando.md: -------------------------------------------------------------------------------- 1 | # Explorando en el sistema 2 | 3 | Shells de antes permiten explorar el sistema de archivos y ejecutar comandos. Shells modernas como Nu permiten hacer lo mismo. Miremos algunos comandos comunes que puedas usar cuando interactues con el sistema. 4 | 5 | ## Ver contenido de un directorio 6 | 7 | ``` 8 | > ls 9 | ``` 10 | 11 | Cómo hemos visto en otros capítulos, `ls` es un comando para mirar el contenido de una ruta. Nu devolverá el contenido en una tabla que podemos usar. 12 | 13 | El comando `ls` también recibe un argumento opcional para cambiar qué te gustaría ver. Por ejemplo, podemos enumerar los archivos que terminan en ".txt" 14 | 15 | ``` 16 | > ls *.txt 17 | ---+--------------+------+----------+---------+--------------+-------------- 18 | # | name | type | readonly | size | accessed | modified 19 | ---+--------------+------+----------+---------+--------------+-------------- 20 | 0 | history.txt | File | | 1.3 KB | 2 months ago | a day ago 21 | 1 | readonly.txt | File | readonly | | 2 months ago | 2 months ago 22 | ---+--------------+------+----------+---------+--------------+-------------- 23 | ``` 24 | 25 | El asterisco (\*) en el argumento que pasamos "\*.txt" a veces se llama comodín o glob. Nos permite complementar cualquier cosa. Puedes leer el glob "\*.txt" como "complementa cualquier archivo siempre y cuando termine en '.txt'" 26 | 27 | Nu también usa globs modernos permitiendo acceder directorios más profundos. 28 | 29 | ``` 30 | > ls **/*.rs 31 | -----+-----------------------------------------------------+------+----------+----------+----------------+---------------- 32 | # | name | type | readonly | size | accessed | modified 33 | -----+-----------------------------------------------------+------+----------+----------+----------------+---------------- 34 | 0 | src/cli.rs | File | | 19.1 KB | 15 hours ago | 15 hours ago 35 | 1 | src/commands/args.rs | File | | 244 B | 2 months ago | 2 months ago 36 | 2 | src/commands/autoview.rs | File | | 2.5 KB | 15 hours ago | 15 hours ago 37 | 3 | src/commands/cd.rs | File | | 277 B | a week ago | a week ago 38 | 4 | src/commands/classified.rs | File | | 13.5 KB | 15 hours ago | 15 hours ago 39 | 5 | src/commands/clip.rs | File | | 2.0 KB | 2 days ago | 2 days ago 40 | ``` 41 | 42 | Aquí estamos mirando cualquier archivo que termine en ".rs" y los dos asteriscos indican "en cualquier directorio empezando desde aquí" 43 | 44 | ## Cambiar el directorio actual 45 | 46 | ``` 47 | > cd nuevo_directorio 48 | ``` 49 | 50 | Para cambiar del directorio actual a uno nuevo usamos el comando `cd`. Al igual que en otras shells, podemos usar tanto el nombre del directorio o si deseamos subir a un directorio podemos usar el acceso directo `..`. 51 | 52 | ## Comandos del sistema de archivos 53 | 54 | Nu también proporciona algunos comandos básicos del sistema de archivos que funcionan multiplataforma. 55 | 56 | Podemos mover un item de un lugar a otro usando el comando `mv`: 57 | 58 | ``` 59 | > mv item ubicacion 60 | ``` 61 | 62 | Podemos copiar un item de un lugar a otro: 63 | 64 | ``` 65 | > cp item ubicacion 66 | ``` 67 | 68 | Podemos eliminar un item. 69 | 70 | ``` 71 | > rm item 72 | ``` 73 | 74 | Los tres comandos también pueden usar las capacidades de glob que vimos previamente con `ls`. 75 | 76 | Finalmente, podemos crear un directorio usando el comando `mkdir`: 77 | 78 | ``` 79 | > mkdir nuevo_directorio 80 | ``` -------------------------------------------------------------------------------- /en/installation.md: -------------------------------------------------------------------------------- 1 | # Installing Nu 2 | 3 | The best way currently to get Nu up and running is to install either from [crates.io](https://crates.io) or to build it from source. 4 | 5 | ## Getting Ready 6 | 7 | Before we can install Nu, we need to make sure our system has the necessary requirements. Currently, this means making sure we have both the Rust toolchain and local dependencies installed. 8 | 9 | ### Installing Rust 10 | 11 | If we don't already have Rust on our system, the best way to install it via [rustup](https://rustup.rs/). Rustup is a way of managing Rust installations, including managing using different Rust versions. 12 | 13 | Nu currently requires the **nightly** version of Rust. When you first open "rustup" it will ask what version of Rust you wish to install: 14 | 15 | ``` 16 | Current installation options: 17 | 18 | default host triple: x86_64-unknown-linux-gnu 19 | default toolchain: stable 20 | modify PATH variable: yes 21 | 22 | 1) Proceed with installation (default) 23 | 2) Customize installation 24 | 3) Cancel installation 25 | ``` 26 | 27 | Select option #2 to customize the installation, 28 | 29 | ``` 30 | Default host triple? 31 | ``` 32 | 33 | Hit enter here to select the default. 34 | 35 | ``` 36 | Default toolchain? (stable/beta/nightly/none) 37 | ``` 38 | 39 | Make sure to type "nightly" here and press enter. This should give this setup: 40 | 41 | ``` 42 | Modify PATH variable? (y/n) 43 | ``` 44 | 45 | You can optionally update your path. This is generally a good idea, as it makes later steps easier. 46 | 47 | 48 | ``` 49 | Current installation options: 50 | 51 | default host triple: x86_64-unknown-linux-gnu 52 | default toolchain: nightly 53 | modify PATH variable: yes 54 | 55 | 1) Proceed with installation (default) 56 | 2) Customize installation 57 | 3) Cancel installation 58 | ``` 59 | 60 | You can see that our default toolchain has now changed to the nightly toolchain. If this sounds a bit risky, don't worry. The Rust compiler is run through a full battery of tests. The nightly compiler is often as reliable as the stable version. 61 | 62 | Once we are ready, we press 1 and then enter. After this point, we can follow the instructions "rustup" gives us and we should have a working Rust compiler on our system. 63 | 64 | If you'd rather not install Rust via "rustup", you can also install it via other methods (eg from a package in a Linux distro). Just be sure to install a recent nightly version of the toolchain. 65 | 66 | ## Dependencies 67 | 68 | ### Debian/Ubuntu 69 | 70 | You will need to install the "libssl-dev" package: 71 | 72 | ``` 73 | apt install libssl-dev 74 | ``` 75 | 76 | Linux users who wish to use the `rawkey` or `clipboard` optional features will need to install the "libx11-dev" and "libxcb-composite0-dev" packages: 77 | 78 | ``` 79 | apt install libxcb-composite0-dev libx11-dev 80 | ``` 81 | 82 | ### macOS 83 | 84 | Using [homebrew](https://brew.sh/), you will need to install the "openssl" formula: 85 | 86 | ``` 87 | brew install openssl 88 | ``` 89 | 90 | ## Installing from [crates.io](https://crates.io) 91 | 92 | Once we have the dependencies Nu needs, we can install it using the `cargo` command that comes with the Rust compiler. 93 | 94 | ``` 95 | > cargo install nu 96 | ``` 97 | 98 | That's it! The cargo tool will do the work of downloading Nu and its source dependencies, building it, and installing it into the cargo bin path so that we can run it. 99 | 100 | Once installed, we can run Nu using the `nu` command: 101 | 102 | ``` 103 | $ nu 104 | /home/jonathan/Source> 105 | ``` 106 | 107 | ## Building from source 108 | 109 | We can also build our own Nu from source directly from github. This gives us immediate access to the latest Nu features and bugfixes. 110 | 111 | ``` 112 | > git clone https://github.com/nushell/nushell.git 113 | ``` 114 | 115 | Git will clone the main nushell repo for us. From there, we can build and run Nu: 116 | 117 | ``` 118 | > cd nushell 119 | nushell> cargo build && cargo run 120 | ``` 121 | 122 | You can also build and run Nu in release mode: 123 | 124 | ``` 125 | nushell> cargo build --release && cargo run --release 126 | ``` 127 | 128 | People familiar with Rust may wonder why we do both a "build" and a "run" step if "run" does a build by default. This is to get around a shortcoming of the new `default-run` option in Cargo, and ensure that all plugins are built, though this may not be required in the future. 129 | 130 | **Note:** If you are working with both debug and release builds, be sure to run `cargo clean` when you switch between them. Because Nu will look for plugins in both debug and release directories, it may pick up versions of the plugin you don't intend to use. 131 | -------------------------------------------------------------------------------- /es/instalacion.md: -------------------------------------------------------------------------------- 1 | # Instalando Nu 2 | 3 | La mejor manera actualmente para poner en marcha Nu es instalándolo a través de [crates.io](https://crates.io) o compilarlo desde la fuente. 4 | 5 | ## Preparación 6 | 7 | Antes de que podamos instalar Nu, necesitamos asegurarnos de que nuestro sistema tenga los requerimientos necesarios. Actualmente significa que debemos verificar tener instalado tanto el Rust toolchain así como las dependencias locales. 8 | 9 | ### Instalando Rust 10 | 11 | En el caso de que no dispongamos de Rust en nuestro sistema la mejor manera de instalarlo es mediante [rustup](https://rustup.rs/). Rustup es una manera de manejar instalaciones de Rust incluyendo distintas versiones de Rust. 12 | 13 | Nu actualmente requiere la versión **nightly** de Rust. En el momento de abrir "rustup" te solicitará qué versión de Rust deseas instalar: 14 | 15 | ``` 16 | Current installation options: 17 | 18 | default host triple: x86_64-unknown-linux-gnu 19 | default toolchain: stable 20 | modify PATH variable: yes 21 | 22 | 1) Proceed with installation (default) 23 | 2) Customize installation 24 | 3) Cancel installation 25 | ``` 26 | 27 | Selecciona la opción #2 para personalizar la instalación, 28 | 29 | ``` 30 | Default host triple? 31 | ``` 32 | 33 | Presiona enter aquí para seleccionar el predeterminado. 34 | 35 | ``` 36 | Default toolchain? (stable/beta/nightly/none) 37 | ``` 38 | 39 | Asegúrate de ingresar "nightly" aquí y presiona enter. Esto debe darte esta configuración: 40 | 41 | ``` 42 | Modify PATH variable? (y/n) 43 | ``` 44 | 45 | Opcionalmente puedes actualizar el path. Esto es generalmente una buena idea debido a que los próximos pasos serán más fáciles. 46 | 47 | 48 | ``` 49 | Current installation options: 50 | 51 | default host triple: x86_64-unknown-linux-gnu 52 | default toolchain: nightly 53 | modify PATH variable: yes 54 | 55 | 1) Proceed with installation (default) 56 | 2) Customize installation 57 | 3) Cancel installation 58 | ``` 59 | 60 | Puedes observar el toolchain predeterminado ahora cambió a la versión nightly. No te preocupes si esto suena un poco arriesgado. El compilador Rust se ejecuta a través de una batería llena de pruebas. La versión nightly del compilador suele ser tan confiable como la versión stable. 61 | 62 | Una vez que estamos listos presionamos 1 y luego enter. Posterior a este paso podemos seguir las instrucciones que "rustup" nos proporciona y deberíamos tener un compilador Rust funcionando en nuestro sistema. 63 | 64 | Si prefieres no instalar Rust mediante "rustup", también puedes instalar a través de otros métodos (Ej. un paquete en alguna distro de Linux). Solo asegúrate de instalar una versión nightly reciente del toolchain. 65 | 66 | ## Dependencias 67 | 68 | ### Debian/Ubuntu 69 | 70 | Vas a necesitar instalar "libssl-dev": 71 | 72 | ``` 73 | apt install libssl-dev 74 | ``` 75 | 76 | Usuarios de Linux que desean usar las funcionalidades opcionales `rawkey` o `clipboard` necesitarán instalar los paquetes "libx11-dev" y "libxcb-composite0-dev": 77 | 78 | ``` 79 | apt install libx11-dev libxcb-composite0-dev 80 | ``` 81 | 82 | ### macOS 83 | 84 | Usando [homebrew](https://brew.sh/), vas a necesitar instalar la fórmula "openssl": 85 | 86 | ``` 87 | brew install openssl 88 | ``` 89 | 90 | ## Instalando desde [crates.io](https://crates.io) 91 | 92 | Una vez instaladas las depependencias que Nu necesita, podemos instalarla usando el comando `cargo` que viene con el compilador Rust. 93 | 94 | ``` 95 | > cargo install nu 96 | ``` 97 | 98 | ¡Eso es todo! Cargo hará el trabajo de descarga Nu junto con sus dependencias, construirla e instalarla en el bin path de cargo para que podamos arrancarlo. 99 | 100 | Finalizada la instalación podemos ejecutar Nu usando el comando `nu`: 101 | 102 | ``` 103 | $ nu 104 | /home/jonathan/Source> 105 | ``` 106 | 107 | ## Construyendo desde la fuente 108 | 109 | También podemos contruir nuestro propio Nu directamente desde github. Esto nos da acceso inmediato a las últimas funcionalidades y corrección de bugs. 110 | 111 | ``` 112 | > git clone https://github.com/nushell/nushell.git 113 | ``` 114 | 115 | Git nos clonará el repositorio principal de Nu. Partiendo de ahí podemos contruir y arrancar Nu: 116 | 117 | ``` 118 | > cd nushell 119 | nushell> cargo build && cargo run 120 | ``` 121 | 122 | También puedes construir y arrancar Nu en modo release: 123 | 124 | ``` 125 | nushell> cargo build --release && cargo run --release 126 | ``` 127 | Gente familiarizada con Rust se preguntará la razón por la que hacemos un paso "build" y otro paso "run" si "run" construye por defecto. Esto es para evitar una deficiencia de la nueva opción `default-run` en Cargo y asegurar que todos los plugins se construyan aunque puede que esto no sea necesario en el futuro. 128 | 129 | **Nota:** Si te encuentras trabajando tanto en modo debug y release, asegúrate de ejecutar `cargo clean` cuando cambies entre ellas. Nu buscará plugins en los directorios tanto de debug así como release y puede suceder que cargue versiones de un plugin que no tienes intenciones de usar. -------------------------------------------------------------------------------- /en/loading_data.md: -------------------------------------------------------------------------------- 1 | # Loading data 2 | 3 | Earlier we saw how you can use commands like `ls`, `ps`, `date`, and `sys` to load information about your files, processes, time of date, and the system itself. Each command gives us a table of information that we can explore. There are other ways we can load in a table of data to work with. 4 | 5 | ## Opening files 6 | 7 | One of Nu's most powerful assets in working with data is the `open` command. It is a multi-tool that can work with a number of different data formats. To see what this means, let's try opening a json file: 8 | 9 | ``` 10 | > open editors/vscode/package.json 11 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 12 | name | descript | author | license | version | reposito | publishe | categori | keywords | engines | activati | main | contribu | scripts | devDepen 13 | | ion | | | | ry | r | es | | | onEvents | | tes | | dencies 14 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 15 | lark | Lark | Lark | MIT | 1.0.0 | [object] | vscode | [0 | [1 item] | [object] | [1 item] | ./out/ex | [object] | [object] | [object] 16 | | support | develope | | | | | items] | | | | tension | | | 17 | | for VS | rs | | | | | | | | | | | | 18 | | Code | | | | | | | | | | | | | 19 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 20 | ``` 21 | 22 | In a similar way to `ls`, opening a file type that Nu understands will give us back something that is more than just text (or a stream of bytes). Here we open a "package.json" file from a JavaScript project. Nu can recognize and open the JSON text and give back a table of data. 23 | 24 | If we wanted to check the version of the project we were looking at, we can use the `get` command. 25 | 26 | ``` 27 | > open editors/vscode/package.json | get version 28 | 1.0.0 29 | ``` 30 | 31 | Nu currently supports the following formats for loading data directly into tables: 32 | 33 | * json 34 | * yaml 35 | * toml 36 | * xml 37 | * csv 38 | * ini 39 | 40 | But what happens if you load a text file that isn't one of these? Let's try it: 41 | 42 | ``` 43 | > open README.md 44 | ``` 45 | 46 | We're shown the contents of the file. If the file is too large, we get a handy scroll-view to look at the file and then jump back to the terminal. To help with readability, Nu will also syntax-highlight common file formats like source files, markdown, and more. 47 | 48 | Below the surface, what Nu sees in these text files is on large string. Next, we'll talk about how to work with these strings to get the data we need out of them. 49 | 50 | ## Working with strings 51 | 52 | An important part of working with data coming from outside Nu is that it's not always in a format that Nu understands. Often this data is given to us as a string. 53 | 54 | Let's imagine that we're given this data file: 55 | 56 | ``` 57 | > open people.txt 58 | Octavia | Butler | Writer 59 | Bob | Ross | Painter 60 | Antonio | Vivaldi | Composer 61 | ``` 62 | Each bit of data we want is separated by the pipe ('|') symbol, and each person is on a separate line. Nu doesn't have a pipe-delimited file format by default, so we'll have to parse this ourselves. 63 | 64 | The first thing we want to do when bringing in the file is to work with it a line at a time: 65 | 66 | ``` 67 | > open people.txt | lines 68 | ---+------------------------------ 69 | # | value 70 | ---+------------------------------ 71 | 0 | Octavia | Butler | Writer 72 | 1 | Bob | Ross | Painter 73 | 2 | Antonio | Vivaldi | Composer 74 | ---+------------------------------ 75 | ``` 76 | 77 | We can see that we're working with the lines because we're back into a table. Our next step is to see if we can split up the rows into something a little more useful. For that, we'll use the `split-column` command. `split-column`, as the name implies, gives us a way to split a delimited string into columns. We tell it what the delimiter is, and it does the rest: 78 | 79 | ``` 80 | > open people.txt | lines | split-column "|" 81 | ---+----------+-----------+----------- 82 | # | Column1 | Column2 | Column3 83 | ---+----------+-----------+----------- 84 | 0 | Octavia | Butler | Writer 85 | 1 | Bob | Ross | Painter 86 | 2 | Antonio | Vivaldi | Composer 87 | ---+----------+-----------+----------- 88 | ``` 89 | 90 | That almost looks correct. Looks like there is extra space there. Let's change our delimiter: 91 | 92 | ``` 93 | > open people.txt | lines | split-column " | " 94 | ---+---------+---------+---------- 95 | # | Column1 | Column2 | Column3 96 | ---+---------+---------+---------- 97 | 0 | Octavia | Butler | Writer 98 | 1 | Bob | Ross | Painter 99 | 2 | Antonio | Vivaldi | Composer 100 | ---+---------+---------+---------- 101 | ``` 102 | 103 | Not bad. The `split-column` command gives us data we can use. It also goes ahead and gives us default column names: 104 | 105 | ``` 106 | > open people.txt | lines | split-column " | " | get Column1 107 | ---+--------- 108 | # | value 109 | ---+--------- 110 | 0 | Octavia 111 | 1 | Bob 112 | 2 | Antonio 113 | ---+--------- 114 | ``` 115 | 116 | We can also name our columns instead of using the default names: 117 | 118 | ``` 119 | > open people.txt | lines | split-column " | " first_name last_name job 120 | ---+------------+-----------+---------- 121 | # | first_name | last_name | job 122 | ---+------------+-----------+---------- 123 | 0 | Octavia | Butler | Writer 124 | 1 | Bob | Ross | Painter 125 | 2 | Antonio | Vivaldi | Composer 126 | ---+------------+-----------+---------- 127 | ``` 128 | 129 | Now that our data is in a table, we can use all the commands we've used on tables before: 130 | 131 | ``` 132 | > open people.txt | lines | split-column " | " first_name last_name job | sort-by first_name 133 | ---+------------+-----------+---------- 134 | # | first_name | last_name | job 135 | ---+------------+-----------+---------- 136 | 0 | Antonio | Vivaldi | Composer 137 | 1 | Bob | Ross | Painter 138 | 2 | Octavia | Butler | Writer 139 | ---+------------+-----------+---------- 140 | ``` 141 | 142 | There are other commands you can use to work with strings: 143 | * split-row 144 | * str 145 | * lines 146 | * size 147 | * trim 148 | 149 | There is also a set of helper commands we can call if we know the data has a structure that Nu should be able to understand. For example, let's open a Rust lock file: 150 | 151 | ``` 152 | > open Cargo.lock 153 | # This file is automatically @generated by Cargo. 154 | # It is not intended for manual editing. 155 | [[package]] 156 | name = "adhoc_derive" 157 | version = "0.1.2" 158 | ``` 159 | 160 | The "Cargo.lock" file is actually a .toml file, but the file extension isn't .toml. That's okay, we can use the `from-toml` command: 161 | 162 | ``` 163 | > open Cargo.lock | from-toml 164 | ----------+------------- 165 | metadata | package 166 | ----------+------------- 167 | [object] | [405 items] 168 | ----------+------------- 169 | ``` 170 | 171 | There is a `from-` command for each of the structed data text formats that Nu can open and understand. 172 | 173 | ## Opening in raw mode 174 | 175 | While it's helpful to be able to open a file and immediate work with a table of its data, this is not always what you want to do. To get to the underlying text, the `open` command can take an optional flag: 176 | 177 | ``` 178 | > open Cargo.toml --raw 179 | [package] name = "nu" 180 | version = "0.1.3" 181 | authors = ["Yehuda Katz ", "Jonathan Turner "] 182 | description = "A shell for the GitHub era" 183 | license = "MIT" 184 | ``` 185 | 186 | ## Opening URLs 187 | 188 | In addition to loading files from your filesystem, you can also give the `open` command a URL. This will fetch the contents of the URL from the internet and return it to you: 189 | 190 | ``` 191 | > open https://www.jonathanturner.org/feed.xml 192 | ---------- 193 | rss 194 | ---------- 195 | [1 item] 196 | ---------- 197 | ``` 198 | -------------------------------------------------------------------------------- /en/shells_in_shells.md: -------------------------------------------------------------------------------- 1 | # Shells in shells 2 | 3 | ## Working in multiple directories 4 | 5 | While it's common to work in one directory, it can be handy to work in multiple places at the same time. For this, Nu offers the concept of "shells". As the name implies, they're a way of running multiple shells in one, allowing you to quickly jump between working directories and more. 6 | 7 | To get started, let's enter a directory: 8 | 9 | ``` 10 | /home/jonathan/Source/lark(master)> enter ../lark 11 | lark(master)> ls 12 | ----+----------------+-----------+----------+---------+---------------+--------------- 13 | # | name | type | readonly | size | accessed | modified 14 | ----+----------------+-----------+----------+---------+---------------+--------------- 15 | 0 | Cargo.toml | File | | 2.2 KB | 6 months ago | 6 months ago 16 | 1 | target | Directory | | 4.1 KB | 10 months ago | 6 months ago 17 | 2 | notes | Directory | | 4.1 KB | 10 months ago | 6 months ago 18 | ``` 19 | 20 | Entering is similar to changing directories (as we saw with the `cd` command). This allows you to jump into a directory to work in it. Instead of changing the directory, we now are in two directories. To see this more clearly, we can use the `shells` command to list the current directories we have active: 21 | 22 | ``` 23 | /home/jonathan/Source/lark(master)> shells 24 | ---+---+------------+------------------------------- 25 | # | | name | path 26 | ---+---+------------+------------------------------- 27 | 0 | | filesystem | /home/jonathan/Source/nushell 28 | 1 | X | filesystem | /home/jonathan/Source/lark 29 | ---+---+------------+------------------------------- 30 | ``` 31 | 32 | The `shells` command shows use there are two shells currently active: our original "nushell" source directory and now this new "lark" directory. 33 | 34 | We can jump between these shells with the `n` and `p` shortcuts, short for "next" and "previous": 35 | 36 | ``` 37 | /home/jonathan/Source/lark(master)> n 38 | /home/jonathan/Source/nushell(master)> p 39 | /home/jonathan/Source/lark(master)> 40 | ``` 41 | 42 | We can see the directory changing, but we're always able to get back to a previous directory we were working on. This allows us to work in multiple directories in the same session. 43 | 44 | ## Exiting the shell 45 | 46 | You can leave a shell you have `enter`ed using the `exit` command. If this is the last open shell, Nu will quit. 47 | 48 | You can always quit Nu, even if multiple shells are active by passing the `--now` flag to the exit command. Like so: `exit --now` 49 | 50 | ## Going beyond directories 51 | 52 | Nu can also create shells from other things aside from paths in a filesystem. Let's say, for example, you're working with a large data set and don't want to lose your place inside of it. 53 | 54 | To see how this works, let's do the following exercise. Currently, we list the [Nu plugins](plugins.md) we have developed in the "Cargo.toml" file. Let's say we just created a new plugin in the src/plugins directory called "doc.rs", and we're interested to know if is listed in the "Cargo.toml" as well so that it can be compiled and installed correctly for Nu. 55 | 56 | Let's `enter` the file "Cargo.toml" from Nu's source code: 57 | 58 | ``` 59 | /Users/andresrobalino/Code/nushell(master)> enter Cargo.toml 60 | /> ls 61 | ------------+--------------+------------------+----------+---------- 62 | bin | dependencies | dev-dependencies | lib | package 63 | ------------+--------------+------------------+----------+---------- 64 | [11 items] | [object] | [object] | [object] | [object] 65 | ------------+--------------+------------------+----------+---------- 66 | ``` 67 | 68 | For the moment we've only `enter`ed the file and we can look what's in it from the table `ls` gives back. If you pay close attention, this time we've entered a file format that Nu understands (.toml). Nu also projects the contents of the file in a filesystem-like so we can explore it as if it were a regular filesystem. 69 | 70 | Before we continue, let's check the active shells: 71 | 72 | ``` 73 | /> shells 74 | ---+---+-------------------------------------------------+------------------------------------ 75 | # | | name | path 76 | ---+---+-------------------------------------------------+------------------------------------ 77 | 0 | | filesystem | /Users/andresrobalino/Code/nushell 78 | 1 | X | {/Users/andresrobalino/Code/nushell/Cargo.toml} | / 79 | ---+---+-------------------------------------------------+------------------------------------ 80 | 81 | ``` 82 | 83 | We can observe that we have two active shells and telling us we are currently inside of "Cargo.toml" with a default root path "/". Let's view the contents again: 84 | 85 | ``` 86 | /> ls 87 | ------------+--------------+------------------+----------+---------- 88 | bin | dependencies | dev-dependencies | lib | package 89 | ------------+--------------+------------------+----------+---------- 90 | [11 items] | [object] | [object] | [object] | [object] 91 | ------------+--------------+------------------+----------+---------- 92 | ``` 93 | 94 | What we're looking for might be inside of the "bin" column. So let's go into there: 95 | 96 | ``` 97 | > cd bin 98 | /bin> ls 99 | ----+----------------------+--------------------------- 100 | # | name | path 101 | ----+----------------------+--------------------------- 102 | 0 | nu_plugin_inc | src/plugins/inc.rs 103 | 1 | nu_plugin_sum | src/plugins/sum.rs 104 | 2 | nu_plugin_add | src/plugins/add.rs 105 | 3 | nu_plugin_edit | src/plugins/edit.rs 106 | 4 | nu_plugin_str | src/plugins/str.rs 107 | 5 | nu_plugin_skip | src/plugins/skip.rs 108 | 6 | nu_plugin_sys | src/plugins/sys.rs 109 | 7 | nu_plugin_tree | src/plugins/tree.rs 110 | 8 | nu_plugin_binaryview | src/plugins/binaryview.rs 111 | 9 | nu_plugin_textview | src/plugins/textview.rs 112 | 10 | nu | src/main.rs 113 | ----+----------------------+--------------------------- 114 | ``` 115 | 116 | From here, we can always jump back to the directory we were working in before using p (for previous). 117 | 118 | ``` 119 | /bin> p 120 | ``` 121 | 122 | Let's verify the shells again: 123 | 124 | ``` 125 | /Users/andresrobalino/Code/nushell(master)> shells 126 | ---+---+-------------------------------------------------+------------------------------------ 127 | # | | name | path 128 | ---+---+-------------------------------------------------+------------------------------------ 129 | 0 | X | filesystem | /Users/andresrobalino/Code/nushell 130 | 1 | | {/Users/andresrobalino/Code/nushell/Cargo.toml} | /bin 131 | ---+---+-------------------------------------------------+------------------------------------ 132 | 133 | ``` 134 | 135 | We are back at the directory we were working in before entering the file "Cargo.toml". Now let's go into the directory where the source code of the plugins are and track them down: 136 | 137 | ``` 138 | /Users/andresrobalino/Code/nushell(master)> cd src/plugins/ 139 | /Users/andresrobalino/Code/nushell/src/plugins(master)> ls 140 | ----+---------------+------+----------+---------+------------+------------ 141 | # | name | type | readonly | size | accessed | modified 142 | ----+---------------+------+----------+---------+------------+------------ 143 | 0 | doc.rs | File | | 3.0 KB | a week ago | a week ago 144 | 1 | sum.rs | File | | 3.0 KB | a week ago | a week ago 145 | 2 | inc.rs | File | | 11.8 KB | a week ago | a week ago 146 | 3 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 147 | 4 | edit.rs | File | | 2.7 KB | a week ago | a week ago 148 | 5 | str.rs | File | | 21.4 KB | 5 days ago | 5 days ago 149 | 6 | secret.rs | File | | 1.8 KB | 2 days ago | 2 days ago 150 | 7 | skip.rs | File | | 1.7 KB | a week ago | a week ago 151 | 8 | binaryview.rs | File | | 13.0 KB | a week ago | a week ago 152 | 9 | tree.rs | File | | 3.0 KB | a week ago | a week ago 153 | 10 | add.rs | File | | 2.7 KB | a week ago | a week ago 154 | 11 | textview.rs | File | | 9.4 KB | 5 days ago | 5 days ago 155 | ----+---------------+------+----------+---------+------------+------------ 156 | ``` 157 | 158 | We can now compare the two to see if there are any missing or additional plugins we need to add to our file (clearly we need to add it to "Cargo.toml"!) 159 | -------------------------------------------------------------------------------- /es/cargando_datos.md: -------------------------------------------------------------------------------- 1 | # Cargando datos 2 | 3 | Hemos visto como puedes usar comandos como `ls`, `ps`, `date`, y `sys` para cargar información sobre los archivos, procesos, hora de fecha, y del mismo sistema. Cada comando nos entrega una tabla de información que podemos explorar. Hay otras maneras de cargar datos en una tabla de datos para trabajar. 4 | 5 | ## Abriendo archivos 6 | 7 | Una de las funciones más destacadas de Nu para trabajar con datos es el comando `open`. Es una multi-herramienta que puede trabajar con varios formatos de datos. Para ver qué significa esto intentemos abrir un archivo en formato json: 8 | 9 | ``` 10 | > open editors/vscode/package.json 11 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 12 | name | descript | author | license | version | reposito | publishe | categori | keywords | engines | activati | main | contribu | scripts | devDepen 13 | | ion | | | | ry | r | es | | | onEvents | | tes | | dencies 14 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 15 | lark | Lark | Lark | MIT | 1.0.0 | [object] | vscode | [0 | [1 item] | [object] | [1 item] | ./out/ex | [object] | [object] | [object] 16 | | support | develope | | | | | items] | | | | tension | | | 17 | | for VS | rs | | | | | | | | | | | | 18 | | Code | | | | | | | | | | | | | 19 | ------+----------+----------+---------+---------+----------+----------+----------+----------+----------+----------+----------+----------+----------+---------- 20 | ``` 21 | 22 | De manera similar a `ls`, abrir un tipo de archivo que Nu entienda nos devolverá algo más que solo texto (o una secuencia de bytes). Aquí abrimos el archivo "package.json" de un proyecto de JavaScript. Nu puede reconocer y abrir el texto en JSON y devolvernos una tabla de datos. 23 | 24 | Si deseamos revisar la versión del proyecto que estamos mirando podemos usar el comando `get`. 25 | 26 | ``` 27 | > open editors/vscode/package.json | get version 28 | 1.0.0 29 | ``` 30 | 31 | Actualmente Nu soporta los siguiente formatos para cargar datos directamente a tablas: 32 | 33 | * json 34 | * yaml 35 | * toml 36 | * xml 37 | * csv 38 | * ini 39 | 40 | ¿Pero qué sucede si cargas un archivo de texto que no sea de estos? Probemos: 41 | 42 | ``` 43 | > open README.md 44 | ``` 45 | 46 | Se nos muestra el contenido del archivo. Si el archivo es muy grande obtendremos una vista práctica desplazable para mirar el archivo y luego regresar a la terminal. Para ayudar con legibilidad Nu resaltará la sintaxis de formatos comunes de archivos como de código, markdown, y más. 47 | 48 | Debajo de la superficie Nu mira estos archivos de texto como una cadena larga. Próximamente hablaremos de cómo trabajar con estas cadenas para extraer los datos que necesitemos de ellas. 49 | 50 | ## Trabajando con cadenas 51 | 52 | Una parte importante de trabajar con datos llegando fuera de Nu es que no siempre estará en formato que Nu entiende. Comúnmente estos datos son proporcionados como una cadena. 53 | 54 | Imaginemos que nos proporcionan estos datos de archivo: 55 | 56 | ``` 57 | > open gente.txt 58 | Octavia | Butler | Writer 59 | Bob | Ross | Painter 60 | Antonio | Vivaldi | Composer 61 | ``` 62 | 63 | Cada pedazo de dato que deseamos está separada por el símbolo de tubería (pipe '|'), y cada persona está en líneas separadas. Nu no contiene un formato de archivo delimitado con pleca ('|') predeterminado, por lo que tendremos que parsearlo nosotros mismos. 64 | 65 | Lo primero que queremos hacer al cargar el archivo es trabajarlo línea por línea: 66 | 67 | ``` 68 | > open gente.txt | lines 69 | ---+------------------------------ 70 | # | value 71 | ---+------------------------------ 72 | 0 | Octavia | Butler | Writer 73 | 1 | Bob | Ross | Painter 74 | 2 | Antonio | Vivaldi | Composer 75 | ---+------------------------------ 76 | ``` 77 | 78 | Podemos darnos cuenta que estamos trabajando con las líneas porque estamos de vuelta a una tabla. Nuestro próximo paso es mirar si podemos dividir las filas a algo más útil. Para eso, usaremos el comando `split-column`. `split-column`, como implica el nombre, nos da una manera de dividir una cadena delimitada a columnas. Indicamos cuál es el delimitador y hace el resto: 79 | 80 | ``` 81 | > open gente.txt | lines | split-column "|" 82 | ---+----------+-----------+----------- 83 | # | Column1 | Column2 | Column3 84 | ---+----------+-----------+----------- 85 | 0 | Octavia | Butler | Writer 86 | 1 | Bob | Ross | Painter 87 | 2 | Antonio | Vivaldi | Composer 88 | ---+----------+-----------+----------- 89 | ``` 90 | 91 | Casi se ve correcto. Parece que hay espacio extra ahí. Cambiemos nuestro delimitador: 92 | 93 | ``` 94 | > open gente.txt | lines | split-column " | " 95 | ---+---------+---------+---------- 96 | # | Column1 | Column2 | Column3 97 | ---+---------+---------+---------- 98 | 0 | Octavia | Butler | Writer 99 | 1 | Bob | Ross | Painter 100 | 2 | Antonio | Vivaldi | Composer 101 | ---+---------+---------+---------- 102 | ``` 103 | 104 | Nada mal. El comando `split-column` nos da datos que podemos usar. Adicionalmente nos crea nombres de columnas predeterminadas: 105 | 106 | ``` 107 | > open gente.txt | lines | split-column " | " | get Column1 108 | ---+--------- 109 | # | value 110 | ---+--------- 111 | 0 | Octavia 112 | 1 | Bob 113 | 2 | Antonio 114 | ---+--------- 115 | ``` 116 | 117 | También podemos nombrar nuestras columnas en vez de usar nombres predeterminados: 118 | 119 | ``` 120 | > open gente.txt | lines | split-column " | " primer_nombre apellido trabajo 121 | ---+---------------+-----------+---------- 122 | # | primer_nombre | apellido | trabajo 123 | ---+---------------+-----------+---------- 124 | 0 | Octavia | Butler | Writer 125 | 1 | Bob | Ross | Painter 126 | 2 | Antonio | Vivaldi | Composer 127 | ---+---------------+-----------+---------- 128 | ``` 129 | 130 | Ahora que tenemos nuestros datos en una tabla podemos usar todos los comandos que hemos usado en tablas antes: 131 | 132 | ``` 133 | > open gente.txt | lines | split-column " | " primer_nombre apellido trabajo | sort-by primer_nombre 134 | ---+---------------+-----------+---------- 135 | # | primer_nombre | apellido | trabajo 136 | ---+---------------+-----------+---------- 137 | 0 | Antonio | Vivaldi | Composer 138 | 1 | Bob | Ross | Painter 139 | 2 | Octavia | Butler | Writer 140 | ---+---------------+-----------+---------- 141 | ``` 142 | 143 | Hay otros comandos que puedes usar para trabajar con cadenas: 144 | * split-row 145 | * str 146 | * lines 147 | * size 148 | * trim 149 | 150 | También hay un conjunto de comandos auxiliares que podemos llamar si conocemos de antemano que los datos tienen una estructura que Nu debería de entender. Por ejemplo, abramos un Rust archivo lock: 151 | 152 | ``` 153 | > open Cargo.lock 154 | # This file is automatically @generated by Cargo. 155 | # It is not intended for manual editing. 156 | [[package]] 157 | name = "adhoc_derive" 158 | version = "0.1.2" 159 | ``` 160 | 161 | El archivo "Cargo.lock" es un archivo en formato .toml pero la extensión del archivo no es .toml. Está bien, podemos usar el comando `from-toml`: 162 | 163 | ``` 164 | > open Cargo.lock | from-toml 165 | ----------+------------- 166 | metadata | package 167 | ----------+------------- 168 | [object] | [405 items] 169 | ----------+------------- 170 | ``` 171 | 172 | Hay el comando `from-` para cada dato estructurado de formatos de texto que Nu puede abrir y entender. 173 | 174 | ## Abriendo en modo crudo 175 | 176 | Mientras es útil poder abrir un archivo e inmediatamente trabajar con una tabla de sus datos, esto no siempre es lo que deseas hacer. Para llegar al texto subyacente, el comando `open` puede tomar una bandera opcional: 177 | 178 | ``` 179 | > open Cargo.toml --raw 180 | [package] 181 | name = "nu" 182 | version = "0.1.3" 183 | authors = ["Yehuda Katz ", "Jonathan Turner "] 184 | description = "A shell for the GitHub era" 185 | license = "MIT" 186 | ``` 187 | 188 | ## Abriendo URLs 189 | 190 | Además de cargar archivos desde tu archivos de sistema, también puedes proporcionar al comando `open` una URL. Esto cargará el contenido de la URL por internet y devolvértela: 191 | 192 | ``` 193 | > open http://www.andresrobalino.com/feed.xml 194 | ---------- 195 | rss 196 | ---------- 197 | [1 item] 198 | ---------- 199 | ``` 200 | -------------------------------------------------------------------------------- /es/shells_en_shells.md: -------------------------------------------------------------------------------- 1 | # Shells en shells 2 | 3 | ## Trabajando con múltiples directorios 4 | 5 | Mientras es común trabajar en un directorio puede ser beneficioso trabajar en múltiples lugares al mismo tiempo. Para esto Nu ofrece el concepto de "shells". Tal como implica, son una manera de tener activo múltiples shells en uno permitiendote rápidamente saltar entre directorios de trabajo y más. 6 | 7 | Para empezar entremos a un directorio: 8 | 9 | ``` 10 | /home/jonathan/Source/nushell(master)> enter ../lark 11 | /home/jonathan/Source/lark(master)> ls 12 | ----+----------------+-----------+----------+---------+---------------+--------------- 13 | # | name | type | readonly | size | accessed | modified 14 | ----+----------------+-----------+----------+---------+---------------+--------------- 15 | 0 | Cargo.toml | File | | 2.2 KB | 6 months ago | 6 months ago 16 | 1 | target | Directory | | 4.1 KB | 10 months ago | 6 months ago 17 | 2 | notes | Directory | | 4.1 KB | 10 months ago | 6 months ago 18 | ``` 19 | 20 | Entrar es similar a cambiar directorios (como vimos previamente con el comando `cd`). Esto permite saltar al directorio para trabajar dentro del mismo. En lugar de cambiar de directorio, ahora estamos en dos directorios. Para ver esto con más claridad podemos usar el comando `shells` que enumera los directorios actualmente activos: 21 | 22 | ``` 23 | /home/jonathan/Source/lark(master)> shells 24 | ---+---+------------+------------------------------- 25 | # | | name | path 26 | ---+---+------------+------------------------------- 27 | 0 | | filesystem | /home/jonathan/Source/nushell 28 | 1 | X | filesystem | /home/jonathan/Source/lark 29 | ---+---+------------+------------------------------- 30 | ``` 31 | 32 | El comando `shells` nos muestra que hay dos shells activos: nuestro directorio fuente original "nushell" y ahora este nuevo directorio "lark". 33 | 34 | Podemos saltar entre estas shells con los accesos directos `n` y `p`, cortos de siguiente "next" y previo "previous": 35 | 36 | ``` 37 | /home/jonathan/Source/lark(master)> n 38 | /home/jonathan/Source/nushell(master)> p 39 | /home/jonathan/Source/lark(master)> 40 | ``` 41 | 42 | Podemos notar el directorio cambiando pero también siempre podremos regresar al directorio previo en el cual estábamos trabajando. Esto nos permite trabajar en múltiples directorio en la misma sesión. 43 | 44 | ## Saliendo del shell 45 | 46 | Puedes salir de una shell que hayas entrado (usando `enter`) a través del comando `exit`. Si esta es la última shell, Nu se cerrará. 47 | 48 | Siempre puedes cerrar Nu incluso si tienes múltiples shells activas usando el comando `exit` pasando la bandera `--now` de la siguiente forma `exit --now` 49 | 50 | ## Más allá de los directorios 51 | 52 | Nu también puede crear shells de otras cosas aparte de las rutas del sistema de archivos. Digamos por ejemplo que estás trabajando con un gran conjunto de datos y no deseas perderte dentro del mismo. 53 | 54 | Para ver cómo funciona haremos el siguiente ejercicio. Actualmente en Nu tenemos enumerados los [complementos](plugins.md) desarrollados (plugins) en "Cargo.toml" digamos que también acabamos de crear un nuevo complemento en el directorio src/plugins llamado "doc.rs" y nos interesa saber que se encuentre enumerado también en "Cargo.toml" para que se instale al compilar Nu. 55 | 56 | Entraremos al archivo "Cargo.toml" del código fuente de Nu: 57 | 58 | ``` 59 | /Users/andresrobalino/Code/nushell(master)> enter Cargo.toml 60 | /> ls 61 | ------------+--------------+------------------+----------+---------- 62 | bin | dependencies | dev-dependencies | lib | package 63 | ------------+--------------+------------------+----------+---------- 64 | [11 items] | [object] | [object] | [object] | [object] 65 | ------------+--------------+------------------+----------+---------- 66 | ``` 67 | 68 | Por el momento solo hemos entrado al archivo y podemos observar en la tabla devuelta por `ls` lo que hay. Si prestas atención hemos entrado a un archivo con formato que reconoce Nu (.toml). Nu también nos proyecta el contenido del archivo en forma de sistema de archivos para explorarlo como si estuvieramos dentro de un sistema de archivos. 69 | 70 | Antes de continuar revisemos las shells activas: 71 | 72 | ``` 73 | /> shells 74 | ---+---+-------------------------------------------------+------------------------------------ 75 | # | | name | path 76 | ---+---+-------------------------------------------------+------------------------------------ 77 | 0 | | filesystem | /Users/andresrobalino/Code/nushell 78 | 1 | X | {/Users/andresrobalino/Code/nushell/Cargo.toml} | / 79 | ---+---+-------------------------------------------------+------------------------------------ 80 | 81 | ``` 82 | 83 | Observamos que hay dos activas indicándonos que nos encontramos dentro de "Cargo.toml" en la ruta predeterminada "/". Revisemos el listado de nuevo: 84 | 85 | ``` 86 | /> ls 87 | ------------+--------------+------------------+----------+---------- 88 | bin | dependencies | dev-dependencies | lib | package 89 | ------------+--------------+------------------+----------+---------- 90 | [11 items] | [object] | [object] | [object] | [object] 91 | ------------+--------------+------------------+----------+---------- 92 | ``` 93 | 94 | Puede que los complementos se encuentren en "bin", vamos ahí: 95 | 96 | ``` 97 | > cd bin 98 | /bin> ls 99 | ----+----------------------+--------------------------- 100 | # | name | path 101 | ----+----------------------+--------------------------- 102 | 0 | nu_plugin_inc | src/plugins/inc.rs 103 | 1 | nu_plugin_sum | src/plugins/sum.rs 104 | 2 | nu_plugin_add | src/plugins/add.rs 105 | 3 | nu_plugin_edit | src/plugins/edit.rs 106 | 4 | nu_plugin_str | src/plugins/str.rs 107 | 5 | nu_plugin_skip | src/plugins/skip.rs 108 | 6 | nu_plugin_sys | src/plugins/sys.rs 109 | 7 | nu_plugin_tree | src/plugins/tree.rs 110 | 8 | nu_plugin_binaryview | src/plugins/binaryview.rs 111 | 9 | nu_plugin_textview | src/plugins/textview.rs 112 | 10 | nu | src/main.rs 113 | ----+----------------------+--------------------------- 114 | ``` 115 | 116 | Notar que siempre podemos saltar de vuelta al directorio en el que estuvimos trabajando usando `p` (para previo). 117 | 118 | ``` 119 | /bin> p 120 | ``` 121 | 122 | Verifiquemos las shells: 123 | 124 | ``` 125 | /Users/andresrobalino/Code/nushell(master)> shells 126 | ---+---+-------------------------------------------------+------------------------------------ 127 | # | | name | path 128 | ---+---+-------------------------------------------------+------------------------------------ 129 | 0 | X | filesystem | /Users/andresrobalino/Code/nushell 130 | 1 | | {/Users/andresrobalino/Code/nushell/Cargo.toml} | /bin 131 | ---+---+-------------------------------------------------+------------------------------------ 132 | 133 | ``` 134 | 135 | Nos encontramos ahora en la shell donde estuvimos antes de entrar al archivo "Cargo.toml", vamos al directorio donde se encuentra el código fuente de los complementos (plugins): 136 | 137 | ``` 138 | /Users/andresrobalino/Code/nushell(master)> cd src/plugins/ 139 | /Users/andresrobalino/Code/nushell/src/plugins(master)> ls 140 | ----+---------------+------+----------+---------+------------+------------ 141 | # | name | type | readonly | size | accessed | modified 142 | ----+---------------+------+----------+---------+------------+------------ 143 | 0 | doc.rs | File | | 3.0 KB | a week ago | a week ago 144 | 1 | sum.rs | File | | 3.0 KB | a week ago | a week ago 145 | 2 | inc.rs | File | | 11.8 KB | a week ago | a week ago 146 | 3 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 147 | 4 | edit.rs | File | | 2.7 KB | a week ago | a week ago 148 | 5 | str.rs | File | | 21.4 KB | 5 days ago | 5 days ago 149 | 6 | secret.rs | File | | 1.8 KB | 2 days ago | 2 days ago 150 | 7 | skip.rs | File | | 1.7 KB | a week ago | a week ago 151 | 8 | binaryview.rs | File | | 13.0 KB | a week ago | a week ago 152 | 9 | tree.rs | File | | 3.0 KB | a week ago | a week ago 153 | 10 | add.rs | File | | 2.7 KB | a week ago | a week ago 154 | 11 | textview.rs | File | | 9.4 KB | 5 days ago | 5 days ago 155 | ----+---------------+------+----------+---------+------------+------------ 156 | ``` 157 | 158 | Ahora podemos comparar los dos para verificar si faltan complementos adicionales o si hay complementos adicionales que necesitemos agregar a nuestro archivo "Cargo.toml" (¡y claramente falta agregarlo a "Cargo.toml"!) 159 | -------------------------------------------------------------------------------- /en/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Hello, and welcome to the Nushell project. The goal of this project is to take the Unix philosophy of shells, where pipes connect simple commands together, and bring it to the modern style of development. 4 | 5 | Nu takes cues from a lot of familiar territory: traditional shells like bash, advanced shells like PowerShell, functional programming, systems programming, and more. But rather than trying to be the jack of all trades, Nu focuses its energy on doing a few things well: 6 | 7 | * Create a flexible crossplatform shell for the modern, GitHub-era programmer 8 | * Allow you to mix and match commandline applications with a shell that understands the structure of your data 9 | * Have the level of UX polish that modern CLI apps provide 10 | 11 | The easiest way to see what Nu can do is to start with some examples, so let's dive in. 12 | 13 | The first thing you'll notice when you run a command like `ls` is that instead of a block of text coming back, you get a structured table. 14 | 15 | ``` 16 | > ls 17 | ----+------------------+-----------+----------+----------+----------------+---------------- 18 | # | name | type | readonly | size | accessed | modified 19 | ----+------------------+-----------+----------+----------+----------------+---------------- 20 | 0 | .azure | Directory | | 4.1 KB | 2 months ago | a week ago 21 | 1 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago 22 | 2 | Cargo.toml | File | | 3.1 KB | 17 minutes ago | 17 minutes ago 23 | 3 | LICENSE | File | | 1.1 KB | 2 months ago | 2 months ago 24 | 4 | readonly.txt | File | readonly | | a month ago | a month ago 25 | 5 | target | Directory | | 4.1 KB | 2 days ago | 15 minutes ago 26 | ... 27 | ``` 28 | 29 | The table is more than just showing the directory in a different way. Just like tables in a spreadsheet, this table allows us to work with the data more interactively. 30 | 31 | The first thing we'll do is to sort our table by the name. To do this, we'll take the output from `ls` and feed it into a command that can sort tables based on the contents of a column. 32 | 33 | ``` 34 | > ls | sort-by name 35 | ----+------------------+-----------+----------+----------+----------------+---------------- 36 | # | name | type | readonly | size | accessed | modified 37 | ----+------------------+-----------+----------+----------+----------------+---------------- 38 | 0 | .azure | Directory | | 4.1 KB | 2 months ago | a week ago 39 | 1 | .cargo | Directory | | 4.1 KB | 2 months ago | 2 months ago 40 | 2 | .editorconfig | File | | 148 B | 2 months ago | 2 months ago 41 | 3 | .git | Directory | | 4.1 KB | 2 months ago | 20 minutes ago 42 | 4 | .gitignore | File | | 58 B | a week ago | a week ago 43 | 5 | .vscode | Directory | | 4.1 KB | a month ago | a month ago 44 | ... 45 | ``` 46 | 47 | You can see that to make this work we didn't pass commandline arguments to `ls`. Instead, we used the `sort-by` command that Nu provides to do the sorting of the output of the `ls` command. 48 | 49 | Nu provides many commands that can work on tables. For example, we could filter the contents of the `ls` table so that it only shows files over 4 kilobytes: 50 | 51 | ``` 52 | > ls | where size > 4kb 53 | ----+----------------+------+----------+----------+----------------+---------------- 54 | # | name | type | readonly | size | accessed | modified 55 | ----+----------------+------+----------+----------+----------------+---------------- 56 | 0 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago 57 | 1 | README.md | File | | 11.1 KB | 2 days ago | 2 days ago 58 | 2 | IMG_1291.png | File | | 589.0 KB | a month ago | a month ago 59 | 3 | IMG_1381.jpg | File | | 81.0 KB | a month ago | 4 months ago 60 | 4 | butterfly.jpeg | File | | 4.2 KB | a month ago | a month ago 61 | 5 | Cargo.lock | File | | 199.6 KB | 22 minutes ago | 22 minutes ago 62 | ``` 63 | 64 | Just as in the Unix philosophy, being able to have commands talk to each other gives us ways to mix-and-match in many different combinations. Let's look at a different command: 65 | 66 | ``` 67 | > ps 68 | -----+-------+----------+------+-------------------------------------------------------------------------------- 69 | # | pid | status | cpu | name 70 | -----+-------+----------+------+-------------------------------------------------------------------------------- 71 | 0 | 1003 | Unknown | 0.00 | 72 | 1 | 1515 | Sleeping | 0.00 | /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy 73 | 2 | 2128 | Sleeping | 0.00 | /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy 74 | 3 | 2285 | Unknown | 0.00 | 75 | 4 | 8872 | Sleeping | 0.00 | /usr/lib/gvfs/gvfsd-dnssd--spawner:1.23/org/gtk/gvfs/exec_spaw/4 76 | 5 | 1594 | Sleeping | 0.00 | /usr/lib/ibus/ibus-engine-simple 77 | ``` 78 | 79 | You may be familiar with the `ps` command if you've used Linux. With it, we can get a list of all the current processes that the system is running, what their status is, and what their name is. We can also see the CPU load for the process. 80 | 81 | What if we wanted to show the processes that were actively using the CPU? Just like we did with the `ls` command earlier, we can also work with the table that the `ps` command gives back to us: 82 | 83 | ``` 84 | > ps | where cpu > 10 85 | ---+-------+----------+-------+----------------------------- 86 | # | pid | status | cpu | name 87 | ---+-------+----------+-------+----------------------------- 88 | 0 | 1992 | Sleeping | 44.52 | /usr/bin/gnome-shell 89 | 1 | 1069 | Sleeping | 16.15 | 90 | 2 | 24116 | Sleeping | 13.70 | /opt/google/chrome/chrome 91 | 3 | 21976 | Sleeping | 12.67 | /usr/share/discord/Discord 92 | ``` 93 | 94 | So far, we've seen using `ls` and `ps` to list files and processes. Nu also offers other commands that can create tables of useful information. Next, let's explore `date` and `sys`. 95 | 96 | Running `date` gives us information about the current day and time: 97 | 98 | ``` 99 | > date 100 | ------+-------+-----+------+--------+--------+---------- 101 | year | month | day | hour | minute | second | timezone 102 | ------+-------+-----+------+--------+--------+---------- 103 | 2019 | 8 | 17 | 19 | 20 | 50 | +12:00 104 | ------+-------+-----+------+--------+--------+---------- 105 | ``` 106 | 107 | Running `sys` gives information about the system that Nu is running on: 108 | 109 | ``` 110 | > sys 111 | ----------+----------+-----------+----------+-----------+----------- 112 | host | cpu | disks | mem | temp | net 113 | ----------+----------+-----------+----------+-----------+----------- 114 | [object] | [object] | [3 items] | [object] | [3 items] | [3 items] 115 | ----------+----------+-----------+----------+-----------+----------- 116 | ``` 117 | 118 | This is a bit different than the tables we saw before. The `sys` command gives us a table that contains structured tables in the cells instead of simple values. To take a look at this data, we need to select the column to view: 119 | 120 | ``` 121 | > sys | get host 122 | -------+------------------+----------+--------+----------+---------- 123 | name | release | hostname | arch | uptime | users 124 | -------+------------------+----------+--------+----------+---------- 125 | Linux | 5.0.0-21-generic | pop-os | x86_64 | [object] | [1 item] 126 | -------+------------------+----------+--------+----------+---------- 127 | ``` 128 | 129 | The `get` command lets us jump into the contents of a column of the table. Here, we're looking into the "host" column, which contains information about the host that Nu is running on. The name of the OS, the hostname, the CPU, and more. Let's get the name of the users on the system: 130 | 131 | ``` 132 | > sys | get host.users 133 | jonathan 134 | ``` 135 | 136 | Right now, there's just one user on the system named "jonathan". You'll notice that we can pass a path and not just the name of the column. Nu will take the path and go to the corresponding bit of data in the table. 137 | 138 | You might have noticed something else that's different. Rather than having a table of data, we have just the single element: the string "jonathan". Nu works with both tables of data as well as strings. String are an important part of working with commands outside of Nu. 139 | 140 | Let's see how strings work outside of Nu in action. We'll take our example from before and run the external `echo` command, which is built into most OSes: 141 | 142 | ``` 143 | > sys | get host.users | echo $it 144 | jonathan 145 | ``` 146 | 147 | If this looks very similar to what we had before, you have a keen eye! It is similar, but with one important different: we've called `echo` with the value we saw earlier. This allows us to pass data out of Nu into `echo` (or any command outside of Nu, like `git` for example) 148 | 149 | -------------------------------------------------------------------------------- /es/introduccion.md: -------------------------------------------------------------------------------- 1 | # Introducción 2 | 3 | Hola, y bienvenido al proyecto Nushell. El objectivo de este proyecto es tomar la filosofía Unix de shells, dónde tuberías (pipes) conectan comandos simples juntos y llevarlos al estilo moderno de desarrollo. 4 | 5 | Nu toma ideas de muchos territorios familiares: shells tradicionales como bash, shells avanzadas como PowerShell, programación funcional, programación de sistemas, y más. Pero, en lugar de ser un "Todo en uno", No enfoca su energía en hacer algunas cosas bien: 6 | 7 | * Crear una shell flexible de plataforma cruzada para la programadora moderna de la era GitHub 8 | * Permitirte mezclar y combinar aplicaciones de línea de comandos con una shell que comprende la estructura de tus datos. 9 | * 10 | * Tenga el brillo UX que proporcionan las aplicaciones modernas CLI. 11 | 12 | La manera más facil de ver qué puede hacer Nu es empezando con ejemplos, así que vamos a sumergirnos. 13 | 14 | Lo primero que notarás al ejercutar un comando como `ls` es que en lugar de un bloque de texto que regresa, recibirás una tabla estructurada. 15 | 16 | ``` 17 | > ls 18 | ----+------------------+-----------+----------+----------+----------------+---------------- 19 | # | name | type | readonly | size | accessed | modified 20 | ----+------------------+-----------+----------+----------+----------------+---------------- 21 | 0 | .azure | Directory | | 4.1 KB | 2 months ago | a week ago 22 | 1 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago 23 | 2 | Cargo.toml | File | | 3.1 KB | 17 minutes ago | 17 minutes ago 24 | 3 | LICENSE | File | | 1.1 KB | 2 months ago | 2 months ago 25 | 4 | readonly.txt | File | readonly | | a month ago | a month ago 26 | 5 | target | Directory | | 4.1 KB | 2 days ago | 15 minutes ago 27 | ... 28 | ``` 29 | 30 | La tabla es más que solamente mostrar el directorio de una manera diferente. Tanto las tablas en una hoja de cálculo (spreadsheet), esta tabla te permite trabajar con los datos más interactivamente. 31 | 32 | Lo primero que vamos hacer es ordenar nuestra tabla por nombre. Para poder hacerlo tomaremos la salida de `ls` and alimentarla al comando que ordena tablas basado en el contenido de una columna. 33 | 34 | ``` 35 | > ls | sort-by name 36 | ----+------------------+-----------+----------+----------+----------------+---------------- 37 | # | name | type | readonly | size | accessed | modified 38 | ----+------------------+-----------+----------+----------+----------------+---------------- 39 | 0 | .azure | Directory | | 4.1 KB | 2 months ago | a week ago 40 | 1 | .cargo | Directory | | 4.1 KB | 2 months ago | 2 months ago 41 | 2 | .editorconfig | File | | 148 B | 2 months ago | 2 months ago 42 | 3 | .git | Directory | | 4.1 KB | 2 months ago | 20 minutes ago 43 | 4 | .gitignore | File | | 58 B | a week ago | a week ago 44 | 5 | .vscode | Directory | | 4.1 KB | a month ago | a month ago 45 | ... 46 | ``` 47 | 48 | Puedes observar que para lograrlo no tuvimos que pasar argumentos al comando `ls`. En cambio, nosotros usamos el comando `sort-by` que proporciona Nu para ordenar la salida del comando `ls`. 49 | 50 | Nu proporciona comandos que trabajan con tablas. Por ejemplo, podemos filtrar los contenidos de la tabla de `ls` para únicamente mostrar archivos superiores a 4 kilobytes: 51 | 52 | ``` 53 | > ls | where size > 4kb 54 | ----+----------------+------+----------+----------+----------------+---------------- 55 | # | name | type | readonly | size | accessed | modified 56 | ----+----------------+------+----------+----------+----------------+---------------- 57 | 0 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago 58 | 1 | README.md | File | | 11.1 KB | 2 days ago | 2 days ago 59 | 2 | IMG_1291.png | File | | 589.0 KB | a month ago | a month ago 60 | 3 | IMG_1381.jpg | File | | 81.0 KB | a month ago | 4 months ago 61 | 4 | butterfly.jpeg | File | | 4.2 KB | a month ago | a month ago 62 | 5 | Cargo.lock | File | | 199.6 KB | 22 minutes ago | 22 minutes ago 63 | ``` 64 | 65 | Al igual que en la filosofía Unix, poder hacer que los comandos hablen entre ellos nos da maneras de mezclar y combinar de formas distintas. Probemos otro comando: 66 | 67 | 68 | ``` 69 | > ps 70 | -----+-------+----------+------+-------------------------------------------------------------------------------- 71 | # | pid | status | cpu | name 72 | -----+-------+----------+------+-------------------------------------------------------------------------------- 73 | 0 | 1003 | Unknown | 0.00 | 74 | 1 | 1515 | Sleeping | 0.00 | /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy 75 | 2 | 2128 | Sleeping | 0.00 | /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy 76 | 3 | 2285 | Unknown | 0.00 | 77 | 4 | 8872 | Sleeping | 0.00 | /usr/lib/gvfs/gvfsd-dnssd--spawner:1.23/org/gtk/gvfs/exec_spaw/4 78 | 5 | 1594 | Sleeping | 0.00 | /usr/lib/ibus/ibus-engine-simple 79 | ``` 80 | 81 | Es posible que estés familiarizado con el comando `ps` si has utlizado Linux. Con dicho comando, podemos tener una lista de los procesos actuales que ejecuta el sistema, qué estado tienen y sus nombres. También podemos ver la carga CPU del proceso. 82 | 83 | ¿Qué tal si quisiéramos mostrar los procesos que activamente usan el CPU? Así como hicimos con el comando `ls` previamente, también podemos trabajar con la tabla que nos devuelve `ps`: 84 | 85 | ``` 86 | > ps | where cpu > 10 87 | ---+-------+----------+-------+----------------------------- 88 | # | pid | status | cpu | name 89 | ---+-------+----------+-------+----------------------------- 90 | 0 | 1992 | Sleeping | 44.52 | /usr/bin/gnome-shell 91 | 1 | 1069 | Sleeping | 16.15 | 92 | 2 | 24116 | Sleeping | 13.70 | /opt/google/chrome/chrome 93 | 3 | 21976 | Sleeping | 12.67 | /usr/share/discord/Discord 94 | ``` 95 | 96 | Hasta ahora, hemos visto el uso de `ls` y `ps` para enumerar archivos y procesos. Nu también ofrece otros comandos que pueden crear tablas de información de utilidad. Exploremos a continuación `date` y `sys`. 97 | 98 | Ejecutando `date` nos proporciona información del día y tiempo: 99 | 100 | ``` 101 | > date 102 | ------+-------+-----+------+--------+--------+---------- 103 | year | month | day | hour | minute | second | timezone 104 | ------+-------+-----+------+--------+--------+---------- 105 | 2019 | 8 | 17 | 19 | 20 | 50 | +12:00 106 | ------+-------+-----+------+--------+--------+---------- 107 | ``` 108 | 109 | Ejecutando `sys` devuelve información sobre el sistema en el que se ejecuta Nu: 110 | 111 | ``` 112 | > sys 113 | ----------+----------+-----------+----------+-----------+----------- 114 | host | cpu | disks | mem | temp | net 115 | ----------+----------+-----------+----------+-----------+----------- 116 | [object] | [object] | [3 items] | [object] | [3 items] | [3 items] 117 | ----------+----------+-----------+----------+-----------+----------- 118 | ``` 119 | 120 | Esto es un poco diferente ante las tablas que hemos visto. El comando `sys` nos proporciona una tabla que contiene tablas estructuradas en las celdas en vez de valores simples. Para mirar estos datos necesitamos seleccionar una columa para mostrar: 121 | 122 | ``` 123 | > sys | get host 124 | -------+------------------+----------+--------+----------+---------- 125 | name | release | hostname | arch | uptime | users 126 | -------+------------------+----------+--------+----------+---------- 127 | Linux | 5.0.0-21-generic | pop-os | x86_64 | [object] | [1 item] 128 | -------+------------------+----------+--------+----------+---------- 129 | ``` 130 | 131 | El comando `get` nos permite saltar directo al contenido de una columa de la tabla. Aquí estamos mirando la columna "host" que contiene información del host dónde se está ejecutando Nu. El nombre del sistema operativo, hostanme, CPU, y más. Miremos los nombres de los usuarios en el sistema: 132 | 133 | ``` 134 | > sys | get host.users 135 | jonathan 136 | ``` 137 | 138 | En este momento, solo hay un usuario en el sistema llamado "jonathan". Notarás que podemos pasar una ruta y no únicamente el nombre de una columna. Nu tomará esta ruta e irá a los datos correspondientes en la tabla. 139 | 140 | Es posible que hayas notado algo más que es diferente. En lugar de tener una tabla de datos, tenemos solo un elemento individual: la cadena "jonathan". Nu trabaja tanto con tabla de datos así como cadenas. Cadenas son una parte importante de trabajar con comandos fuera de Nu. 141 | 142 | Miremos en acción cómo funcionan las cadenas fuera de Nu. Tomaremos el ejemplo anterior y ejecutaremos el comando externo `echo`, que se encuentra instalado en la mayoría de los sitemas operativos: 143 | 144 | ``` 145 | > sys | get host.users | echo $it 146 | jonathan 147 | ``` 148 | 149 | Si esto se parece mucho a lo que teníamos antes, ¡tienes buen ojo! Es similar, pero con una diferencia importante: hemos llamado `echo` con el valor que vimos antes. Esto nos permite pasar datos fuera de Nu a `echo` (o cualquier comando fuera de Nu, como `git` por ejemplo) -------------------------------------------------------------------------------- /en/working_with_tables.md: -------------------------------------------------------------------------------- 1 | # Working with tables 2 | 3 | One of the common ways of seeing data in Nu is through a table. Nu comes with a number of commands for working with tables to make it convenient to find what you're looking for, and for narrowing the data to just what you need. 4 | 5 | To start off, let's get a table that we can use: 6 | 7 | ``` 8 | > ls 9 | ---+---------------+------+----------+---------+------------+------------ 10 | # | name | type | readonly | size | accessed | modified 11 | ---+---------------+------+----------+---------+------------+------------ 12 | 0 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 13 | 1 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 14 | 2 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 15 | 3 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 16 | 4 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 17 | 5 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 18 | 6 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 19 | 7 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 20 | 8 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 21 | 9 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 22 | ---+---------------+------+----------+---------+------------+------------ 23 | ``` 24 | 25 | ## Sorting the data 26 | 27 | We can sort a table by calling the `sort-by` command and telling it which columns we want to use in the sort. Let's say we wanted to sort our table by the size of the file: 28 | 29 | ``` 30 | > ls | sort-by size 31 | ---+---------------+------+----------+---------+------------+------------ 32 | # | name | type | readonly | size | accessed | modified 33 | ---+---------------+------+----------+---------+------------+------------ 34 | 0 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 35 | 1 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 36 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 37 | 3 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 38 | 4 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 39 | 5 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 40 | 6 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 41 | 7 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 42 | 8 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 43 | 9 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 44 | ---+---------------+------+----------+---------+------------+------------ 45 | ``` 46 | 47 | We can sort a table by any column that can be compared. For example, we could also have sorted the above using the "name", "accessed", or "modified" columns. 48 | 49 | ## Selecting the data you want 50 | 51 | We can select data from a table by choosing to select specific columns or specific rows. Let's pick a few columns from our table to use: 52 | 53 | ``` 54 | > ls | pick name size 55 | ---+---------------+--------- 56 | # | name | size 57 | ---+---------------+--------- 58 | 0 | add.rs | 2.7 KB 59 | 1 | sum.rs | 3.0 KB 60 | 2 | inc.rs | 11.8 KB 61 | 3 | str.rs | 21.4 KB 62 | 4 | skip.rs | 1.7 KB 63 | 5 | textview.rs | 9.4 KB 64 | 6 | binaryview.rs | 13.0 KB 65 | 7 | edit.rs | 2.7 KB 66 | 8 | tree.rs | 3.0 KB 67 | 9 | sys.rs | 9.2 KB 68 | ---+---------------+--------- 69 | ``` 70 | 71 | This helps to create a table that's more focused on what we need. Next, let's say we want to only look at the 5 smallest files in this directory: 72 | 73 | ``` 74 | > ls | sort-by size | first 5 75 | ---+---------+------+----------+--------+------------+------------ 76 | # | name | type | readonly | size | accessed | modified 77 | ---+---------+------+----------+--------+------------+------------ 78 | 0 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 79 | 1 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 80 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 81 | 3 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 82 | 4 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 83 | ---+---------+------+----------+--------+------------+------------ 84 | ``` 85 | 86 | You'll notice we first sort the table by size to get to the smallest file, and then we use the `first 5` to return the first 5 rows of the table. 87 | 88 | You can also `skip` rows that you don't want. Let's skip the first two of the 5 rows we returned above: 89 | 90 | ``` 91 | > ls | sort-by size | first 5 | skip 2 92 | ---+---------+------+----------+--------+------------+------------ 93 | # | name | type | readonly | size | accessed | modified 94 | ---+---------+------+----------+--------+------------+------------ 95 | 0 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 96 | 1 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 97 | 2 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 98 | ---+---------+------+----------+--------+------------+------------ 99 | ``` 100 | 101 | We've narrowed it to three rows we care about. 102 | 103 | Let's look look at a few other commands for selecting data. You may have wondered why the rows of the table are numbers. This acts as a handy way to get to a single row. Let's sort our table by the file name and then pick one of the rows with the `n-th` command using its row number: 104 | 105 | ``` 106 | > ls | sort-by name 107 | ---+---------------+------+----------+---------+------------+------------ 108 | # | name | type | readonly | size | accessed | modified 109 | ---+---------------+------+----------+---------+------------+------------ 110 | 0 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 111 | 1 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 112 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 113 | 3 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 114 | 4 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 115 | 5 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 116 | 6 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 117 | 7 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 118 | 8 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 119 | 9 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 120 | ---+---------------+------+----------+---------+------------+------------ 121 | 122 | > ls | sort-by name | nth 5 123 | --------+------+----------+---------+------------+------------ 124 | name | type | readonly | size | accessed | modified 125 | --------+------+----------+---------+------------+------------ 126 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 127 | --------+------+----------+---------+------------+------------ 128 | ``` 129 | 130 | ## Getting data out of a table 131 | 132 | So far, we've worked with tables by trimming the table down to only what we need. Sometimes we may want to go a step further and only look at the values in the cells themselves rather than taking a whole column. Let's say, for example, we wanted to only get a list of the names of the files. For this, we use the `get` command: 133 | 134 | ``` 135 | > ls | get name 136 | ---+--------------- 137 | # | value 138 | ---+--------------- 139 | 0 | add.rs 140 | 1 | sum.rs 141 | 2 | inc.rs 142 | 3 | str.rs 143 | 4 | skip.rs 144 | 5 | textview.rs 145 | 6 | binaryview.rs 146 | 7 | edit.rs 147 | 8 | tree.rs 148 | 9 | sys.rs 149 | ---+--------------- 150 | ``` 151 | 152 | We now have the values for each of the filenames. 153 | 154 | This might look like the `pick` command we saw earlier, so let's put that here as well to compare the two: 155 | 156 | ``` 157 | > ls | pick name 158 | ---+--------------- 159 | # | name 160 | ---+--------------- 161 | 0 | add.rs 162 | 1 | sum.rs 163 | 2 | inc.rs 164 | 3 | str.rs 165 | 4 | skip.rs 166 | 5 | textview.rs 167 | 6 | binaryview.rs 168 | 7 | edit.rs 169 | 8 | tree.rs 170 | 9 | sys.rs 171 | ---+--------------- 172 | ``` 173 | 174 | These look very similar! Let's see if we can spell out the difference between these two commands to make it clear: 175 | 176 | * `pick` - creates a new table which includes only the columns specified 177 | * `get` - returns the values inside the column specified 178 | 179 | The one way to tell these apart looking at the table is the characteristic `value` column name, which lets us know that this is going to be a list of values we can work with. 180 | 181 | The `get` command can go one step further and take a path to data deeper in the table. This simplifies working with more complex data, like the structures you might find in a .json file. 182 | 183 | ## Changing data in a table 184 | 185 | In addition to selecting data from a table, we can also update what the table has. We may want to add new columns, or edit the contents of a cell. In Nu, rather than editing in place, each of the commands in the section will return a new table in the pipeline. 186 | 187 | ### Adding a new column 188 | 189 | We can use the `add` command to add a new column to the table. Let's look at an example: 190 | 191 | ``` 192 | > open rustfmt.toml 193 | --------- 194 | edition 195 | --------- 196 | 2018 197 | --------- 198 | ``` 199 | 200 | Let's add an column called "next_edition" with the value 2021: 201 | 202 | ``` 203 | > open rustfmt.toml | add next_edition 2021 204 | ---------+-------------- 205 | edition | next_edition 206 | ---------+-------------- 207 | 2018 | 2021 208 | ---------+-------------- 209 | ``` 210 | 211 | Notice that we if open the original file, the contents have stayed the same: 212 | 213 | ``` 214 | > open rustfmt.toml 215 | --------- 216 | edition 217 | --------- 218 | 2018 219 | --------- 220 | ``` 221 | 222 | Changes in Nu are functional changes, meaning that they work on the values themselves rather than trying to cause a permanent change. This lets us do many different types of work in our 223 | pipeline until we're ready to write out the result with any changes we'd like if we choose to. Here we could write out the result using the `save` command: 224 | 225 | ``` 226 | > open rustfmt.toml | add next_edition 2021 | save rustfmt2.toml 227 | /home/jonathan/Source/nushell(master)> open rustfmt2.toml 228 | ---------+-------------- 229 | edition | next_edition 230 | ---------+-------------- 231 | 2018 | 2021 232 | ---------+-------------- 233 | ``` 234 | 235 | ### Editing a column 236 | 237 | Similarly to the `add` command, we can also use the `edit` command to change the contents of a column to a new value. To see it in action let's open the same file: 238 | 239 | ``` 240 | open rustfmt.toml 241 | --------- 242 | edition 243 | --------- 244 | 2018 245 | --------- 246 | ``` 247 | 248 | And now, let's update the edition to point at the next edition we hope to support: 249 | 250 | ``` 251 | > open rustfmt.toml | edit edition 2021 252 | --------- 253 | edition 254 | --------- 255 | 2021 256 | --------- 257 | ``` 258 | 259 | ### Incrementing values 260 | 261 | There's one more command that Nu supports that will help us work with numbers and versions: `inc`. 262 | 263 | ``` 264 | > open rustfmt.toml 265 | --------- 266 | edition 267 | --------- 268 | 2018 269 | --------- 270 | > open rustfmt.toml | inc edition 271 | --------- 272 | edition 273 | --------- 274 | 2019 275 | --------- 276 | ``` 277 | 278 | Because the value in "edition" is a number, we can use `inc` to update it. Where `inc` really shines is working with versions: 279 | 280 | ``` 281 | > open Cargo.toml | get package.version 282 | 0.1.3 283 | > open Cargo.toml | inc package.version --minor | get package.version 284 | 0.2.0 285 | ``` 286 | 287 | When working with versions, we can use the flag to say how to increment the version: 288 | 289 | * **--major** - increment the major version (0.1.3 -> 1.0.0) 290 | * **--minor** - increment the minor version (0.1.3 -> 0.2.0) 291 | * **--patch** - increment the patch version (0.1.3 -> 0.1.4) 292 | -------------------------------------------------------------------------------- /es/trabajando_con_tablas.md: -------------------------------------------------------------------------------- 1 | # Trabajando con tablas 2 | 3 | Una de las maneras comunes de mirar datos en Nu es a través de una tabla. Nu viene con una serie de comandos que trabajan con tablas para que pueda ser más conveniente encontrar lo que estás buscando y para limitar los datos a solo lo que necesites. 4 | 5 | Para empezar, consigamos una tabla que podamos usar: 6 | 7 | ``` 8 | > ls 9 | ---+---------------+------+----------+---------+------------+------------ 10 | # | name | type | readonly | size | accessed | modified 11 | ---+---------------+------+----------+---------+------------+------------ 12 | 0 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 13 | 1 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 14 | 2 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 15 | 3 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 16 | 4 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 17 | 5 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 18 | 6 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 19 | 7 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 20 | 8 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 21 | 9 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 22 | ---+---------------+------+----------+---------+------------+------------ 23 | ``` 24 | 25 | ## Ordenando los datos 26 | 27 | Podemos ordenar la tabla llamando el comando `sort-by` e indicándole qué columnas queremos usar al ordenar. Digamos que deseamos ordenar nuestra tabla por tamaño de archivo: 28 | 29 | ``` 30 | > ls | sort-by size 31 | ---+---------------+------+----------+---------+------------+------------ 32 | # | name | type | readonly | size | accessed | modified 33 | ---+---------------+------+----------+---------+------------+------------ 34 | 0 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 35 | 1 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 36 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 37 | 3 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 38 | 4 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 39 | 5 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 40 | 6 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 41 | 7 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 42 | 8 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 43 | 9 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 44 | ---+---------------+------+----------+---------+------------+------------ 45 | ``` 46 | 47 | Podemos ordenar una tabla con cualquier columna que pueda ser comparada. Por ejemplo, también pudimos haber ordenador usando las columnas "name", "accessed", o "modified". 48 | 49 | # Seleccionando los datos que quieres 50 | 51 | Podemos seleccionar datos de una tabla seleccionando columnas o filas específicas. Escojamos algunas columnas de nuestra tabla para usar: 52 | 53 | ``` 54 | > ls | pick name size 55 | ---+---------------+--------- 56 | # | name | size 57 | ---+---------------+--------- 58 | 0 | add.rs | 2.7 KB 59 | 1 | sum.rs | 3.0 KB 60 | 2 | inc.rs | 11.8 KB 61 | 3 | str.rs | 21.4 KB 62 | 4 | skip.rs | 1.7 KB 63 | 5 | textview.rs | 9.4 KB 64 | 6 | binaryview.rs | 13.0 KB 65 | 7 | edit.rs | 2.7 KB 66 | 8 | tree.rs | 3.0 KB 67 | 9 | sys.rs | 9.2 KB 68 | ---+---------------+--------- 69 | ``` 70 | 71 | Esto ayuda a crear una table más enfocada para lo que necesitamos. Siguiente, digamos que queremos ver los 5 archivos más livianos de este directorio: 72 | 73 | ``` 74 | > ls | sort-by size | first 5 75 | ---+---------+------+----------+--------+------------+------------ 76 | # | name | type | readonly | size | accessed | modified 77 | ---+---------+------+----------+--------+------------+------------ 78 | 0 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 79 | 1 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 80 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 81 | 3 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 82 | 4 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 83 | ---+---------+------+----------+--------+------------+------------ 84 | ``` 85 | 86 | Notarás que primero ordenamos la tabla por tamaño para llegar hasta el archivo más pequeño y luego usamos `first 5` que nos devuelve las primeras 5 filas de la tabla. 87 | 88 | También puedes saltarte filas con `skip` que no deseas. Saltemos las primeras dos de las 5 filas que obtuvimos arriba: 89 | 90 | ``` 91 | > ls | sort-by size | first 5 | skip 2 92 | ---+---------+------+----------+--------+------------+------------ 93 | # | name | type | readonly | size | accessed | modified 94 | ---+---------+------+----------+--------+------------+------------ 95 | 0 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 96 | 1 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 97 | 2 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 98 | ---+---------+------+----------+--------+------------+------------ 99 | ``` 100 | 101 | Hemos reducido a tres filas que nos interesa. 102 | 103 | Veamos algunos otros comandos para seleccionar datos. Es posible que te hayas preguntado por qué las filas de la tabla son números. Esto actúa como una forma práctica de llegar a una sola fila. Ordenemos nuestra tabla por el nombre del archivo y luego escojamos una de las filas con el comando `n-th` usando el número de fila: 104 | 105 | ``` 106 | > ls | sort-by name 107 | ---+---------------+------+----------+---------+------------+------------ 108 | # | name | type | readonly | size | accessed | modified 109 | ---+---------------+------+----------+---------+------------+------------ 110 | 0 | add.rs | File | | 2.7 KB | 2 days ago | 2 days ago 111 | 1 | binaryview.rs | File | | 13.0 KB | a day ago | a day ago 112 | 2 | edit.rs | File | | 2.7 KB | 2 days ago | 2 days ago 113 | 3 | inc.rs | File | | 11.8 KB | 2 days ago | 2 days ago 114 | 4 | skip.rs | File | | 1.7 KB | 2 days ago | 2 days ago 115 | 5 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 116 | 6 | sum.rs | File | | 3.0 KB | 2 days ago | 2 days ago 117 | 7 | sys.rs | File | | 9.2 KB | 2 days ago | 2 days ago 118 | 8 | textview.rs | File | | 9.4 KB | 2 days ago | 2 days ago 119 | 9 | tree.rs | File | | 3.0 KB | 2 days ago | 2 days ago 120 | ---+---------------+------+----------+---------+------------+------------ 121 | 122 | > ls | sort-by name | nth 5 123 | --------+------+----------+---------+------------+------------ 124 | name | type | readonly | size | accessed | modified 125 | --------+------+----------+---------+------------+------------ 126 | str.rs | File | | 21.4 KB | 2 days ago | 2 days ago 127 | --------+------+----------+---------+------------+------------ 128 | ``` 129 | 130 | ## Obteniendo datos de una tabla 131 | 132 | Hasta ahora hemos trabajado con tablas reduciendo la tabla a solo lo que necesitamos. A veces es posible que queramos ir un paso más allá y solo mirar los valores en las celdas en lugar the tomar una columna completa. Digamos, por ejemplo, que queramos obtener una lista de los nombres de los archivos. Para esto usamos el comando `get`: 133 | 134 | ``` 135 | > ls | get name 136 | ---+--------------- 137 | # | value 138 | ---+--------------- 139 | 0 | add.rs 140 | 1 | sum.rs 141 | 2 | inc.rs 142 | 3 | str.rs 143 | 4 | skip.rs 144 | 5 | textview.rs 145 | 6 | binaryview.rs 146 | 7 | edit.rs 147 | 8 | tree.rs 148 | 9 | sys.rs 149 | ---+--------------- 150 | ``` 151 | 152 | Ahora tenemos los valores de cada nombre de los archivos. 153 | 154 | Puede parecerse al comando `pick` que vimos previamente, probemos `pick` para comparar los dos: 155 | 156 | ``` 157 | > ls | pick name 158 | ---+--------------- 159 | # | name 160 | ---+--------------- 161 | 0 | add.rs 162 | 1 | sum.rs 163 | 2 | inc.rs 164 | 3 | str.rs 165 | 4 | skip.rs 166 | 5 | textview.rs 167 | 6 | binaryview.rs 168 | 7 | edit.rs 169 | 8 | tree.rs 170 | 9 | sys.rs 171 | ---+--------------- 172 | ``` 173 | 174 | ¡Se ven muy similares! Veamos si podemos explicar la diferencia entre estos dos comandos para aclarar: 175 | 176 | * `pick` - crea una tabla donde incluye únicamente las columnas indicadas 177 | * `get` - devuelve los valores dentro de la columna indicada 178 | 179 | La manera de distinguirlas mirando la tabla de forma característica es con el nombre de columna `value` que nos permite saber que será una lista de valores con la que podemos trabajar. 180 | 181 | El comando `get` puede ir más allá y tomar una ruta para datos más profundos en la tabla. Esto simplifica trabajar con datos más complejos como las estructuras que podrías encontrar en archivos .json. 182 | 183 | ## Cambiando datos de una tabla 184 | 185 | Además de seleccionar datos de una tabla, también podemos actualizar lo que contiene una tabla. Es posible que queramos agregar nuevas columnas o editar el contenido de una celda. En Nu, en lugar la misma tabla, cada uno de los comandos en la sección devolvera una nueva tabla en la tubería. 186 | 187 | ### Agregando una nueva columna 188 | 189 | Podemos utilizar el comando `add` para agregar una nueva columna a la tabla. Veamos un ejemplo: 190 | 191 | ``` 192 | > open rustfmt.toml 193 | --------- 194 | edition 195 | --------- 196 | 2018 197 | --------- 198 | ``` 199 | 200 | Agreguemos una columna llamada "next_edition" con el valor 2021: 201 | 202 | ``` 203 | > open rustfmt.toml | add next_edition 2021 204 | ---------+-------------- 205 | edition | next_edition 206 | ---------+-------------- 207 | 2018 | 2021 208 | ---------+-------------- 209 | ``` 210 | 211 | Observa que si abrimos el archivo original el contenido permanece igual: 212 | 213 | ``` 214 | > open rustfmt.toml 215 | --------- 216 | edition 217 | --------- 218 | 2018 219 | --------- 220 | ``` 221 | 222 | Los cambios en Nu son cambios funcionales, lo que significa que funcionan en los valores mismos en vez de causar cambios permanentes. Esto nos permite realizar diferentes tipos de trabajo en nuestra tubería hasta que estemos listos para grabar los resultados con cualquier cambio que nos gustaría si así decidimos. Aquí podríamos grabar los resultados usando el comando `save`: 223 | 224 | ``` 225 | > open rustfmt.toml | add next_edition 2021 | save rustfmt2.toml 226 | /home/jonathan/Source/nushell(master)> open rustfmt2.toml 227 | ---------+-------------- 228 | edition | next_edition 229 | ---------+-------------- 230 | 2018 | 2021 231 | ---------+-------------- 232 | ``` 233 | 234 | ### Editando una columna 235 | 236 | Similarmente al comando `add`, también podemos usar el comando `edit` para cambiar el contenido de una columna a un nuevo valor. Abramos el mismo archivo para verlo en acción: 237 | 238 | ``` 239 | open rustfmt.toml 240 | --------- 241 | edition 242 | --------- 243 | 2018 244 | --------- 245 | ``` 246 | 247 | y ahora, actualizemos la edición y que apunte a la siguiente edición que esperamos soportar: 248 | 249 | ``` 250 | > open rustfmt.toml | edit edition 2021 251 | --------- 252 | edition 253 | --------- 254 | 2021 255 | --------- 256 | ``` 257 | 258 | ### Incrementando valores 259 | 260 | Hay un comando más en Nu que nos ayudará a trabajar con números y versiones: `inc`. 261 | 262 | ``` 263 | > open rustfmt.toml 264 | --------- 265 | edition 266 | --------- 267 | 2018 268 | --------- 269 | > open rustfmt.toml | inc edition 270 | --------- 271 | edition 272 | --------- 273 | 2019 274 | --------- 275 | ``` 276 | 277 | Como el valor en "edition" es un número, podemos usar `inc` para actualizarlo. `inc` realmente brilla cuando trabajamos con versiones: 278 | 279 | ``` 280 | > open Cargo.toml | get package.version 281 | 0.1.3 282 | > open Cargo.toml | inc package.version --minor | get package.version 283 | 0.2.0 284 | ``` 285 | 286 | Cuando trabajamos con versiones podemos usar banderas e indicar cómo incrementar la versión: 287 | 288 | * **--major** - incrementar major (0.1.3 -> 1.0.0) 289 | * **--minor** - incrementar minor (0.1.3 -> 0.2.0) 290 | * **--patch** - incrementar patch (0.1.3 -> 0.1.4) 291 | --------------------------------------------------------------------------------