Skip to content

Add Nushell support#9393

Closed
VitalyAnkh wants to merge 2 commits intowarpdotdev:masterfrom
VitalyAnkh:vitaly/issue-2038-nushell-support
Closed

Add Nushell support#9393
VitalyAnkh wants to merge 2 commits intowarpdotdev:masterfrom
VitalyAnkh:vitaly/issue-2038-nushell-support

Conversation

@VitalyAnkh
Copy link
Copy Markdown

Description

Fixes #2038.

Adds local Nushell (nu) support across Warp's shell model, discovery, launch, bootstrap, command execution, and env-var serialization paths.

  • Adds ShellType::Nu detection for nu, nu.exe, markdown nu/nushell, history/rc files, alias parsing, executable discovery, and shell metadata.
  • Adds Nushell bootstrap scripts that emit Warp lifecycle hooks, prompt markers, alias/env metadata, input-buffer reporting, and in-band generator output.
  • Wires Nushell into available-shell discovery, startup shell settings, local/WSL launch args, bootstrap file handling, command executors, update helpers, and focused tests.
  • Keeps remote SSH/warpify and local child harnesses explicitly unsupported for Nushell until those flows can be implemented with Nu-native semantics.

Testing

  • cargo fmt --all -- --check
  • export PROTOC=$(nix-shell -p protobuf --run 'which protoc'); cargo check -p warp
  • cargo test -p warp env_vars::tests --lib
  • cargo test -p warp test_find_by_command_name_matches_known_shell --lib
  • cargo test -p warp test_trims_comments --lib
  • cargo test -p warp validate_local_harness_shell_rejects_unsupported_shells --lib
  • cargo test -p warp_terminal test_from_name --lib
  • cargo test -p warp_terminal test_from_markdown_language_spec --lib
  • cargo test -p warp_terminal test_nu_parse_aliases --lib
  • nix develop /home/vitalyr/projects/dev/ai/warp#default -c bash -lc 'cd /home/vitalyr/projects/dev/ai/warp-dev && cargo test -p warp_terminal test_nu_parse_aliases --lib'
  • export PROTOC=$(nix-shell -p protobuf --run 'which protoc'); export LIBCLANG_PATH=$(nix eval --raw nixpkgs#llvmPackages.libclang.lib)/lib; cargo clippy -p warp -p warp_terminal --all-targets --tests -- -D warnings
  • Manual Nushell smoke test with nu -n --no-std-lib sourcing the generated bootstrap files.
  • Interactive Nushell pexpect smoke test verified InitShell, CommandFinished, Precmd, Bootstrapped, and Preexec messages around echo hi.

Note: attempted full workspace clippy locally, but this shell lacked pkg-config for alsa-sys; targeted clippy for touched crates passed and GitHub CI should run the full check in the proper environment.

Server API dependencies

None.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Changelog Entries for Stable

CHANGELOG-NEW-FEATURE: Added Nushell as a supported local shell.

Co-Authored-By: Warp agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label Apr 29, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 29, 2026

@VitalyAnkh

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I requested changes on this pull request and posted feedback.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds local Nushell support across shell detection, bootstrap scripts, command execution, environment-variable serialization, and related shell metadata.

Concerns

  • Linux update command construction treats Nushell's success-gated combiner as a plain separator, so update completion can be reported even after package-manager failures.
  • Drive env-var export/copy paths still convert a ShellFamily::Posix value back to ShellType::Bash, which loses Nushell context and emits Bash syntax for Nu users.
  • Nushell detection uses broad substring/suffix checks that can misclassify non-Nu executables as Nushell, especially because nu is only two characters.

Verdict

Found: 0 critical, 4 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

// Nushell does not support POSIX `&&`. There is no direct command separator with the
// same status-gated semantics, so use a plain separator as the least surprising
// fallback for command construction sites that are not Nushell-specific.
ShellType::Nu => "; ",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] and_combiner() is used by the Linux update flow before warp_finish_update; returning a plain ; makes Nushell report the update as finished even when the package-manager command fails. Keep Nu out of status-gated update command construction or use a Nu expression that preserves the success dependency.

Copy link
Copy Markdown
Author

@VitalyAnkh VitalyAnkh Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a654d8: Nu update commands now use a dedicated nu_update_command that wraps package-manager steps and warp_finish_update in one Nushell try/catch block, so finish is not sent after a failed package-manager command. Added regression coverage in test_nu_update_command_gates_finish_update_on_success.

Comment thread app/src/drive/export.rs Outdated
let exported_variables = env_var_collection_model
.string_model
.export_variables("\n", shell_family)
.export_variables("\n", shell_family.into())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] Converting ShellFamily::Posix back to ShellType::Bash loses Nushell context, so exported env-var collections still emit Bash syntax for Nu users. Carry the actual ShellType through this path or add an explicit Nushell export mode.

Copy link
Copy Markdown
Author

@VitalyAnkh VitalyAnkh Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a654d8: Drive export and copy now carry the active session ShellType from active_session_shell_type instead of round-tripping through ShellFamily::Posix -> Bash, so Nu sessions use the Nushell env-var serializer.

Comment thread crates/warp_terminal/src/shell/mod.rs Outdated
Some(ShellType::Zsh)
} else if name == "fish" || name == "-fish" || name.ends_with("/fish") {
Some(ShellType::Fish)
} else if name == "nu" || name == "-nu" || name.ends_with("/nu") || name.ends_with("nu.exe")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] name.ends_with("nu.exe") also matches executables like menu.exe, causing unrelated commands to be detected as Nushell. Compare the basename to nu.exe exactly instead of using a suffix match for this short name.

Copy link
Copy Markdown
Author

@VitalyAnkh VitalyAnkh Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a654d8: ShellType::from_name now compares the executable basename to nu.exe exactly; added regression coverage that menu.exe is not detected as Nu.

Comment thread app/src/terminal/local_tty/shell.rs Outdated
ShellType::Zsh
} else if shell_path.contains("fish") {
ShellType::Fish
} else if shell_path.contains("nu") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] shell_path.contains("nu") is too broad for WSL default-shell detection and can classify any path containing nu as Nushell. Parse the basename with ShellType::from_name or compare the executable name exactly.

Copy link
Copy Markdown
Author

@VitalyAnkh VitalyAnkh Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a654d8: WSL default-shell detection now extracts the basename and delegates to ShellType::from_name; added regression coverage for /usr/bin/menu.exe.

Co-Authored-By: Warp <agent@warp.dev>
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 29, 2026

@VitalyAnkh

I'm checking this implementation PR for association with an explicitly linked issue.

The PR that you've opened seems to contain implementation changes and is associated with issue #2038, but none of those associated issue are marked as ready-to-implement. This PR will be automatically closed. Please see our contribution docs for guidance on when changes are accepted for issues.

Powered by Oz

@oz-for-oss oz-for-oss Bot closed this Apr 29, 2026
@VitalyAnkh
Copy link
Copy Markdown
Author

VitalyAnkh commented Apr 29, 2026

Thanks for taking a look here. Quick update: I realized this implementation PR got ahead of the repo flow — #2038 is still labeled ready-to-spec, so Oz correctly closed this code PR before implementation review.

I’ve opened the required spec-only PR here: #9470. I’ve also been tightening that spec based on Oz’s feedback, especially around the Nushell startup contract, metadata payloads, env-var escaping, update-command failure semantics, and reproducible validation.

Once the spec path is approved and the issue is marked ready for implementation, I’m happy to continue from this branch and keep iterating on the implementation. I care about landing this with good shell-integration behavior and solid tests rather than just making nu launch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NuShell Support

1 participant