nushell/crates/nu-command/src
Darren Schroeder 0805f1fd90
overhaul shell_integration to enable individual control over ansi escape sequences (#12629)
# Description

This PR overhauls the shell_integration system by allowing individual
control over which ansi escape sequences are used. As we continue to
broaden our support for more ansi escape sequences, we can't really have
an all-or-nothing strategy. Some ansi escapes cause problems in certain
operating systems or terminals. We should allow the user to choose which
escapes they want.

TODO:
* Gather feedback
* Should osc7, osc9_9 and osc633p be mutually exclusive?
* Is the naming convention for these settings too nerdy osc2, osc7, etc?

closes #11301

# User-Facing Changes
shell_integration is no longer a boolean value. This is what is
supported in the default_config.nu
```nushell
  shell_integration: {
    # osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title
    osc2: true
    # osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory
    osc7: true
    # osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it
    osc8: true
    # osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal
    osc9_9: false
    # osc133 is several escapes invented by Final Term which include the supported ones below.
    # 133;A - Mark prompt start
    # 133;B - Mark prompt end
    # 133;C - Mark pre-execution
    # 133;D;exit - Mark execution finished with exit code
    # This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is
    osc133: true
    # osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features
    # 633;A - Mark prompt start
    # 633;B - Mark prompt end
    # 633;C - Mark pre-execution
    # 633;D;exit - Mark execution finished with exit code
    # 633;E - NOT IMPLEMENTED - Explicitly set the command line with an optional nonce
    # 633;P;Cwd=<path> - Mark the current working directory and communicate it to the terminal
    # and also helps with the run recent menu in vscode
    osc633: true
    # reset_application_mode is escape \x1b[?1l and was added to help ssh work better
    reset_application_mode: true
  }
```

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-05-02 09:56:50 -04:00
..
bytes Make bytes build accept integer values as individual bytes (#12685) 2024-05-01 17:29:33 -05:00
charting Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
conversions Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
database Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
date Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
debug Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
env Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
experimental Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
filesystem Fix inconsistent print behavior (#12675) 2024-04-27 00:25:11 +00:00
filters Prevent each from swallowing errors when eval_block returns a ListStream (#12412) 2024-05-01 17:24:54 -05:00
formats Msgpack commands (#12664) 2024-04-26 06:23:16 -05:00
generators Fix example wording in seq date (#12665) 2024-04-25 22:12:42 +02:00
hash Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
help Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
math Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
misc Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
network Fix inconsistent print behavior (#12675) 2024-04-27 00:25:11 +00:00
path Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
platform Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
random Range refactor (#12405) 2024-04-06 09:04:56 -05:00
removed Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
shells Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
stor Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
strings Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00
system Remove deprecated flags on run-external (#12659) 2024-04-25 14:17:21 +00:00
viewers overhaul shell_integration to enable individual control over ansi escape sequences (#12629) 2024-05-02 09:56:50 -04:00
default_context.rs Msgpack commands (#12664) 2024-04-26 06:23:16 -05:00
example_test.rs Initial --params implementation (#12249) 2024-03-24 15:40:21 -05:00
lib.rs Initial --params implementation (#12249) 2024-03-24 15:40:21 -05:00
progress_bar.rs remove cp-old (#11622) 2024-01-24 07:38:15 +08:00
sort_utils.rs Rename Value::CustomValue to Value::Custom (#12309) 2024-03-27 22:10:56 +01:00