nushell/crates/nu-command/src
Maxim Zhiburt 718ee3d545
[MVP][WIP] less like pager (#6984)
Run it as `explore`.

#### example

```nu
ls | explore
```

Configuration points in `config.nu` file.
```
  # A 'explore' utility config
   explore_config: {
     highlight: { bg: 'yellow', fg: 'black' }
     status_bar: { bg: '#C4C9C6', fg: '#1D1F21' }
     command_bar: { fg: '#C4C9C6' }
     split_line: '#404040'
     cursor: true
     # selected_column: 'blue'
     # selected_row: { fg: 'yellow', bg: '#C1C2A3' }
     # selected_cell: { fg: 'white', bg: '#777777' }
     # line_shift: false,
     # line_index: false,
     # line_head_top: false,
     # line_head_bottom: false,
   }
```

You can start without a pipeline and type `explore` and it'll give you a
few tips.

![image](https://user-images.githubusercontent.com/343840/205088971-a8c0262f-f222-4641-b13a-027fbd4f5e1a.png)

If you type `:help` you an see the help screen with some information on
what tui keybindings are available.

![image](https://user-images.githubusercontent.com/343840/205089461-c4c54217-7ec4-4fa0-96c0-643d68dc0062.png)

From the `:help` screen you can now hit `i` and that puts you in
`cursor` aka `inspection` mode and you can move the cursor left right up
down and it you put it on an area such as `[table 5 rows]` and hit the
enter key, you'll see something like this, which shows all the `:`
commands. If you hit `esc` it will take you to the previous screen.

![image](https://user-images.githubusercontent.com/343840/205090155-3558a14b-87b7-4072-8dfb-dc8cc2ef4943.png)

If you then type `:try` you'll get this type of window where you can
type in the top portion and see results in the bottom.

![image](https://user-images.githubusercontent.com/343840/205089185-3c065551-0792-43d6-a13c-a52762856209.png)

The `:nu` command is interesting because you can type pipelines like
`:nu ls | sort-by type size` or another pipeline of your choosing such
as `:nu sys` and that will show the table that looks like this, which
we're calling "table mode".

![image](https://user-images.githubusercontent.com/343840/205090809-e686ff0f-6d0b-4347-8ed0-8c59adfbd741.png)

If you hit the `t` key it will now transpose the view to look like this.

![image](https://user-images.githubusercontent.com/343840/205090948-a834d7f2-1713-4dfe-92fe-5432f287df3d.png)

In table mode or transposed table mode you can use the `i` key to
inspect any collapsed field like `{record 8 fields}`, `[table 16 rows]`,
`[list x]`, etc.

One of the original benefits was that when you're in a view that has a
lot of columns, `explore` gives you the ability to scroll left, right,
up, and down.

`explore` is also smart enough to know when you're in table mode versus
preview mode. If you do `open Cargo.toml | explore` you get this.

![image](https://user-images.githubusercontent.com/343840/205091822-cac79130-3a52-4ca8-9210-eba5be30ed58.png)

If you type `open --raw Cargo.toml | explore` you get this where you can
scroll left, right, up, down. This is called preview mode.

![image](https://user-images.githubusercontent.com/343840/205091990-69455191-ab78-4fea-a961-feafafc16d70.png)

When you're in table mode, you can also type `:preview`. So, with `open
--raw Cargo.toml | explore`, if you type `:preview`, it will look like
this.

![image](https://user-images.githubusercontent.com/343840/205092569-436aa55a-0474-48d5-ab71-baddb1f43027.png)

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2022-12-01 09:32:10 -06:00
..
bits add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
bytes add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
charting Split blocks and closures (#7075) 2022-11-10 21:21:49 +13:00
conversions chore: chrono_update (#7132) 2022-11-27 07:19:02 +13:00
core_commands add a more verbose description of operators (#7263) 2022-11-29 15:20:17 +13:00
database Apply clippy fix (#7193) 2022-11-23 16:57:27 +13:00
dataframe fix dfr datetime conversion (#7264) 2022-11-30 17:10:28 -06:00
date chore: chrono_update (#7132) 2022-11-27 07:19:02 +13:00
deprecated Add a deprecation note for removed build-string (#7307) 2022-12-01 16:26:59 +01:00
env Make external command substitution works friendly(like fish shell, trailing ending newlines) (#7156) 2022-11-23 16:51:57 +13:00
experimental Removes export env command (#6468) 2022-09-25 19:52:43 +03:00
filesystem add -f, --force for save command (#7262) 2022-12-01 06:26:17 -06:00
filters Add -n flag to sort (formerly only available on sort-by) (#7293) 2022-12-01 07:11:30 -06:00
formats chore: chrono_update (#7132) 2022-11-27 07:19:02 +13:00
generators fix cal input_output_types signature (#7306) 2022-12-01 07:10:49 -06:00
hash add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
math Add natural logarithm (#7258) 2022-12-01 15:58:05 +01:00
misc Replace all instances of 'column path' in help messages with 'cell path' (#7063) 2022-11-09 21:49:11 -08:00
network Fix fetch/post not erroring on 4xx and 5xx statuses (#7213) 2022-11-23 08:43:12 -08:00
path Fix sort-by, path join and size error arrows (#7199) 2022-11-23 19:22:23 +13:00
platform add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
random add signature information when get help on one command (#7079) 2022-11-20 07:22:42 -06:00
shells Refactor shell listing related code (#6262) 2022-08-08 06:31:24 -05:00
strings Fix sort-by, path join and size error arrows (#7199) 2022-11-23 19:22:23 +13:00
system A set of fixes for stderr redirect (#7219) 2022-11-24 16:58:15 +13:00
viewers [MVP][WIP] less like pager (#6984) 2022-12-01 09:32:10 -06:00
default_context.rs [MVP][WIP] less like pager (#6984) 2022-12-01 09:32:10 -06:00
example_test.rs Add math pi and math e constants (#7258) 2022-12-01 15:58:05 +01:00
input_handler.rs Replace all instances of 'column path' in help messages with 'cell path' (#7063) 2022-11-09 21:49:11 -08:00
lib.rs Feature cleanup (#7182) 2022-11-22 16:58:11 -08:00
sort_utils.rs Fix sort-by, path join and size error arrows (#7199) 2022-11-23 19:22:23 +13:00