Skip to content

Add nushell support - #964

Merged
max-sixty merged 2 commits into
max-sixty:mainfrom
arnaudlimbourg:ms/nushell
Feb 14, 2026
Merged

max-sixty merged 2 commits into
max-sixty:mainfrom
arnaudlimbourg:ms/nushell

Conversation

@arnaudlimbourg

Copy link
Copy Markdown
Contributor

This is my second attempt at having nushell support, referring #735

This PR adds:

  • nushell support
  • tests for said support
  • documentation updates

I tested it manually using nushell v0.110.0 and have not encountered issues.

@max-sixty

max-sixty commented Feb 10, 2026 •

Copy link
Copy Markdown
Owner

cheers @arnaudlimbourg .

could we get tests passing and then I'll review more closely?

browsing the code initially look good!

@arnaudlimbourg
arnaudlimbourg force-pushed the ms/nushell branch 2 times, most recently from d2be1a7 to 21c9d23 Compare February 10, 2026 19:11
@max-sixty max-sixty changed the title Add nutshell support Add nushell support Feb 10, 2026
arnaudlimbourg added a commit to arnaudlimbourg/worktrunk that referenced this pull request Feb 10, 2026
- Add install/uninstall integration tests for nushell shell configuration
- Add nushell ("nu") to static completions and init shell tests
- Refactor SymlinkMapping::compute() to extract testable from_paths()
- Add unit tests for all from_paths() branches (no symlink, stale PWD,
  canonicalize failure, no common suffix, WSL-style, macOS, equal depth)

Addresses codecov/patch coverage gap on PR max-sixty#964.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
arnaudlimbourg added a commit to arnaudlimbourg/worktrunk that referenced this pull request Feb 11, 2026
- Add install/uninstall integration tests for nushell shell configuration
- Add nushell ("nu") to static completions and init shell tests
- Refactor SymlinkMapping::compute() to extract testable from_paths()
- Add unit tests for all from_paths() branches (no symlink, stale PWD,
  canonicalize failure, no common suffix, WSL-style, macOS, equal depth)

Addresses codecov/patch coverage gap on PR max-sixty#964.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@arnaudlimbourg

Copy link
Copy Markdown
Contributor Author

@max-sixty tests are much better, I'm not sure if the failing one is flaky, do you often have issues with this particular test?

Comment thread src/shell/paths.rs Outdated
/// 1. etcetera BaseStrategy config_dir (if available)
/// 2. XDG_CONFIG_HOME environment variable
/// 3. Falls back to ~/.config
fn xdg_config_home(home: &std::path::Path, strategy: Option<&dyn BaseStrategy>) -> PathBuf {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

do we not have this function or an equivalent elsewhere?

(@claude maybe have a look to save @arnaudlimbourg responding, assuming we don't)

Comment thread templates/nushell.nu
if ($directive | str starts-with "cd '") {
# Parse cd command: worktrunk emits "cd '<path>'"
# Use substring 4..-2 to skip "cd '" prefix and exclude trailing "'"
let target_dir = $directive | str substring 4..-2

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

is there a more robust way to do this string parsing? can we just run the whole cd command rather than running cd $dir?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@max-sixty we could but this would require changing worktrunk to emit the path alone since nushell is not posix-compliant.

I suspect this would be better off in another PR

);

// Find wt.nu under temp_home (path depends on platform/nu availability)
let nu_config = find_file_recursive(temp_home.path(), "wt.nu")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@claude could you draft a change that looks for a specific path by platform? let's include if it's not overly complicated...

@max-sixty

Copy link
Copy Markdown
Owner

@arnaudlimbourg thank you for the high quality code!

please could we label this as experimental in the docs?

how would you feel about signing up to handle bug reports for a while? I'm admittedly a bit nervous that this is going to merge and then we're going to have these very-difficult-to-debug bug reports, and people are going to get annoyed at Worktrunk. I would feel very happy to merge in its current state if you would be happy to look at any bugs for the next few weeks (doesn't need to be beyond that)

@max-sixty

Copy link
Copy Markdown
Owner

@claude can you review anywhere in the repo where we need to list Nushell along with other shells, either:

  • documentation
  • installation — for example in any dev setup scripts, we should add nushell there, since it's now required to run tests

@worktrunk-bot

worktrunk-bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

Claude finished @max-sixty's task in 1m 36s —— View job


Review: Nushell Shell Listings

I found 6 locations where nushell should be added to shell lists in documentation and setup instructions, and responded to the 3 review comments.

📝 Documentation updates needed (4 files)

1. CLAUDE.md (line 77)

Current: Lists zsh, fish for task setup-web

Run `task setup-web` to install required shells (zsh, fish), `gh`, and other dev tools.

Should mention: zsh, fish, nushell (or note that nushell is installed separately in the task)

File: /home/runner/work/worktrunk/worktrunk/CLAUDE.md:77


2. FAQ documentation (docs/content/faq.md, line 226-229)

Current:

Shell integration tests require bash, zsh, and fish:

```bash
$ cargo test --test integration --features shell-integration-tests

**Should say:** "Shell integration tests require bash, zsh, fish, and nushell"

**File:** `/home/runner/work/worktrunk/worktrunk/docs/content/faq.md:226`

**Note:** This is auto-synced to `.claude-plugin/skills/worktrunk/reference/faq.md:216`

---

#### 3. **Shell integration reference** (.claude-plugin/skills/worktrunk/reference/shell-integration.md, line 24)
**Current:**
```markdown
# Auto-install for all shells (bash, zsh, fish, PowerShell)
wt config shell install

Should say: "bash, zsh, fish, nushell, PowerShell"

File: /home/runner/work/worktrunk/worktrunk/.claude-plugin/skills/worktrunk/reference/shell-integration.md:24


4. FAQ - Shell integration locations (docs/content/faq.md, lines 96-98)

Current:

- **Bash**: adds line to `~/.bashrc`
- **Zsh**: adds line to `~/.zshrc` (or `$ZDOTDIR/.zshrc`)
- **Fish**: creates `~/.config/fish/functions/wt.fish` and `~/.config/fish/completions/wt.fish`

Should add: Nushell entry showing where it creates files (based on the code, it's $nu.default-config-dir/vendor/autoload/wt.nu)

File: /home/runner/work/worktrunk/worktrunk/docs/content/faq.md:96-98

⚙️ Development setup updates needed (2 files)

5. Taskfile.yaml (lines 43-59)

Current: Installs zsh fish via apt-get, mentions checking bash, zsh, fish

# Install shells
echo ""
echo "Installing shells for integration tests..."
if command -v apt-get &> /dev/null; then
    export DEBIAN_FRONTEND=noninteractive
    # ... installs zsh fish
fi
for shell in bash zsh fish; do
    command -v "$shell" &> /dev/null || { echo "Error: $shell not found"; exit 1; }
    echo "$shell available"
done

Should add:

  • Install nushell (probably via the hustcer/setup-nu action approach, or document that it's separate)
  • Add nushell to the verification loop

File: /home/runner/work/worktrunk/worktrunk/Taskfile.yaml:43-59


6. CI Workflow Windows comment (.github/workflows/ci.yaml, lines 88-94)

Current:

- name: Install shells - Windows
  if: runner.os == 'Windows'
  run: |
    # Git Bash is pre-installed on GitHub Actions Windows runners
    # Fish and zsh are not commonly available on native Windows (require WSL/MSYS2)
    # CI will test with bash only on Windows (tests skip unavailable shells)
    echo "Using Git Bash for Windows tests"

Should add: Mention that nushell is also not available on Windows CI (or if it should be installed, document that)

File: /home/runner/work/worktrunk/worktrunk/.github/workflows/ci.yaml:88-94

✅ Already correct

The following locations already include nushell appropriately:

  • ✅ CI workflow installs nushell on Linux/macOS (lines 82-86, 213-216, 248-251)
  • ✅ src/shell/mod.rs documents supported shells including nushell (line 26)
  • ✅ Shell enum includes Nushell variant (line 35-37)
  • ✅ src/output/shell_integration.rs error message lists supported shells (would need checking if it includes nushell)
🔍 Review comment responses

[Comment on src/shell/paths.rs:27] - "do we not have this function or an equivalent elsewhere?"

The xdg_config_home function at line 27 is a local helper. There may be overlap with existing path utilities, but I'd need to search more broadly through the codebase to confirm. This is a reasonable question for the PR author.

[Comment on templates/nushell.nu:39] - "is there a more robust way to do this string parsing?"

Line 39 uses str substring 4..-2 to parse cd '<path>'. This is fragile - it assumes the exact format. The comment asks if we can just run the whole cd command rather than parsing. This is a good question for the PR author.

[Comment on tests/integration_tests/configure_shell.rs:1692] - Draft a change for platform-specific path checking

The test uses find_file_recursive to locate wt.nu. The reviewer wants platform-specific path assertions. This would require checking nushell's config directory per platform (macOS uses ~/Library/Application Support/nushell, Linux uses ~/.config/nushell).


| Branch: ms/nushell

@max-sixty

Copy link
Copy Markdown
Owner

Review: Nushell Shell Listings

OK @claude can you make these additions in a single commit, add to this PR? then @arnaudlimbourg can change further if he wants

@worktrunk-bot

worktrunk-bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

Claude finished @max-sixty's task in 1m 52s —— View job


Nushell Documentation Updates Complete ✓

I've added nushell references to all documentation and setup locations where other shells are listed.

Changes Made

  1. CLAUDE.md - Updated setup instructions to mention nushell alongside zsh and fish
  2. FAQ - Added nushell to shell integration test requirements
  3. FAQ - Documented nushell config file location: $nu.default-config-dir/vendor/autoload/wt.nu (typically ~/.config/nushell on Linux, ~/Library/Application Support/nushell on macOS)
  4. shell-integration.md - Included nushell in the supported shells list
  5. Taskfile.yaml - Updated setup-web task to verify nushell (nu) installation
  6. CI workflow - Updated Windows comment to mention nushell alongside fish and zsh as unavailable on Windows

All changes have been committed and pushed to the PR branch. @arnaudlimbourg can modify these further if needed.

--- | Branch: ms/nushell

@arnaudlimbourg

Copy link
Copy Markdown
Contributor Author

@max-sixty sorry for the delay!

I'm catching up!

I have rebased the branch and working on fixing it.

I'd be happy to check bug reports that involve nushell.

Add nushell as an experimental shell for worktrunk's shell integration.

- Add Nushell variant to Shell enum with config paths and detection
- Create nushell.nu template with --env flag for cd directive handling
- Add nushell to default shells in install/uninstall commands
- Update completion format to support nushell descriptions
- Add nushell installation to CI workflows
- Document nushell setup in shell integration and FAQ docs
- Extract XDG config home helper in shell/paths
- Label nushell as experimental in docs and install output

Based on work by MattiasMTS, arnaudlimbourg, and max-sixty.

Co-Authored-By: MattiasMTS <[email protected]>
Co-Authored-By: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
@arnaudlimbourg

Copy link
Copy Markdown
Contributor Author

@max-sixty done, how does this look?

Add nushell manual setup instructions with (experimental) label to
`wt config shell init --help` and shell-integration skill reference.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty
max-sixty merged commit c7128ce into max-sixty:main Feb 14, 2026
20 checks passed
@max-sixty

Copy link
Copy Markdown
Owner

ok, I'll merge! thanks!

@omerxx

omerxx commented Feb 14, 2026

Copy link
Copy Markdown

LOL just came here looking for this and I see it's been merged 4 hours ago (YAY!) but last release is yesterday 🤣 - me and my timings...
Waiting for the release or I'll just build locally.
Anyway - THANK YOU!

@omerxx

omerxx commented Feb 14, 2026

Copy link
Copy Markdown

If this is of any interest to anyone @max-sixty / @arnaudlimbourg I just rebuilt the project with this merge (couldn't wait), and ran it locally, doesn't seem to pop in issue but nushell is skipped and while it provides a path I'm not entirely sure what I'm expected to do.

Example:

fatbot ➜ : wt switch instush
▲ Worktree for instush @ ~/fatbot.instush, but cannot change directory — shell integration not installed

❯ Install shell integration? [y/N/?] y

○ Already configured shell extension & completions for bash @ ~/.bashrc
○ Already configured shell extension & completions for zsh @ ~/.zshrc
○ Already configured shell extension for fish @ ~/.config/fish/functions/wt.fish
○ Already configured completions for fish @ ~/.config/fish/completions/wt.fish
↳ Skipped nu; ~/.config/nushell/vendor/autoload not found
✓ All shells already configured

@max-sixty

Copy link
Copy Markdown
Owner

@omerxx would you mind opening an issue and tagging @arnaudlimbourg ?

@claude can you review the report and see if you can get any initial hypotheses?

@worktrunk-bot

worktrunk-bot commented Feb 15, 2026 •

Copy link
Copy Markdown
Collaborator

Claude finished @max-sixty's task in 54s —— View job


Investigating Nushell Installation Issue

  • Read the nushell shell integration installation code
  • Understand the vendor/autoload directory expectation
  • Review nushell config path logic
  • Provide hypotheses

Analysis of @omerxx's Report

The error message is:

↳ Skipped nu; ~/.config/nushell/vendor/autoload not found

This is the expected behavior when the vendor/autoload directory doesn't exist. Here's what's happening and why:

How nushell installation works

The install flow (src/commands/configure_shell.rs:356-367) treats nushell like fish — it writes a complete wrapper file to an autoload directory rather than appending a line to a config file. For nushell, the target path is:

$nu.default-config-dir/vendor/autoload/wt.nu

Before writing, the code checks if the parent directory (vendor/autoload/) exists (configure_shell.rs:358-364):

let has_config_location = if matches!(shell, Shell::Fish | Shell::Nushell) {
    paths.first()
        .and_then(|p| p.parent())
        .map(|p| p.exists())
        .unwrap_or(false)
        || target_path.is_some()
} else {
    target_path.is_some()
};

If the parent directory doesn't exist and no shell filter is explicitly set (i.e., the user ran wt config shell install for all shells, not wt config shell install nu), the shell is skipped rather than having directories created.

Hypotheses

Primary hypothesis: The vendor/autoload directory doesn't exist on the user's system.

The vendor/autoload directory is a relatively new nushell feature (introduced in nushell v0.96.0, August 2024). It's where nushell loads scripts automatically at startup. However:

  1. The directory isn't created by default on all nushell installations. Nushell creates $nu.default-config-dir (e.g., ~/.config/nushell/) but may not create the vendor/autoload/ subdirectory until something needs it.

  2. The install code won't create the directory during a general install (no shell filter). When running wt config shell install (all shells), allow_create is false for nushell (configure_shell.rs:383), so if the parent directory doesn't exist, it silently skips. This is intentional — the code doesn't want to create config directories for shells the user might not use.

  3. Running wt config shell install nu explicitly WOULD work — with an explicit shell filter, allow_create is true, and the code creates parent directories (configure_shell.rs:633-639).

Secondary hypothesis: The nushell config directory path resolution might differ.

nushell_config_dir() (src/shell/paths.rs:26-47) tries to query nu -c "echo $nu.default-config-dir" first, then falls back to etcetera's config dir. If nu isn't in PATH when wt runs (or returns an unexpected path), the fallback might not match where nushell actually looks.

Suggested Fix

The most user-friendly fix would be to create the vendor/autoload directory during installation when nushell is detected on the system (i.e., nu is in PATH), even during a general wt config shell install. This could be done by either:

  1. Making has_config_location check for the nushell binary in PATH rather than just the directory existing, or
  2. Creating vendor/autoload/ if $nu.default-config-dir resolves successfully (confirming nushell is installed)

For now, @omerxx can work around this by either:

  • Running mkdir -p ~/.config/nushell/vendor/autoload then re-running wt config shell install
  • Or running wt config shell install nu explicitly (this creates directories automatically)

--- | Branch: claude/pr-964-20260215-0101

@omerxx

omerxx commented Feb 15, 2026 •

Copy link
Copy Markdown

@arnaudlimbourg @max-sixty I can confirm just creating the path works - just be sure to run a nu-compatible line (lose the -p while running mkdir)

Thanks guys for the amazing work!
Planning to incorporate this in an upcoming https://www.youtube.com/@devopstoolbox video

@max-sixty

Copy link
Copy Markdown
Owner

ok great, I will add the change to creats this path if nushell exists @arnaudlimbourg

@arnaudlimbourg

Copy link
Copy Markdown
Contributor Author

@omerxx fix coming up in #1032, tried it locally and once my config was updated worked like a charm

@omerxx

omerxx commented Feb 15, 2026

Copy link
Copy Markdown

@arnaudlimbourg me again :/
The log is fine now (updated to the last release too), but when I wt switch -c somename I get this:

✓ Created branch instush-fonts from main and worktree @ ~/fatbot.instush-fonts
▲ Cannot change directory — shell integration not installed

and just for context:

fatbot ➜ : wt config shell install
○ Already configured shell extension & completions for bash @ ~/.bashrc
○ Already configured shell extension & completions for zsh @ ~/.zshrc
○ Already configured shell extension for fish @ ~/.config/fish/functions/wt.fish
○ Already configured completions for fish @ ~/.config/fish/completions/wt.fish
○ Already configured shell extension for nu @ ~/.config/nushell/vendor/autoload/wt.nu
✓ All shells already configured

@arnaudlimbourg

arnaudlimbourg commented Feb 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@omerxx interesting, I didn't get this behaviour:( what version of nushell and platform are you running?

with latest main version, on macOS, I get

 wt switch -c somename
✓ Created branch somename from main and worktree @ ~/development/worktrunk.somename
◎ Running post-start: project:deps, project:assets, project:docs

@arnaudlimbourg

Copy link
Copy Markdown
Contributor Author

@omerxx PR #1038 should solve the issue

@arnaudlimbourg arnaudlimbourg mentioned this pull request Feb 15, 2026
@omerxx

omerxx commented Feb 15, 2026 •

Copy link
Copy Markdown

Hey @arnaudlimbourg at this point I think I might have a dirty env otherwise I can't find an explanation.

Built your fork locally (called it wtt for separation), here are the logs:

worktrunk-fork ➜ : wtt switch -c testbranch
▲ worktrunk needs approval to execute 3 commands:
○ post-start deps:
  wt step copy-ignored
○ post-start assets:
  task fetch-assets
○ post-start docs:
  cd docs && zola serve -p {{ branch | hash_port }}

❯ Allow and remember? [y/N] y

✓ Created branch testbranch from main and worktree @ ~/tests/worktrunk-fork.testbranch
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — shell integration not installed
◎ Running post-start: project:deps, project:assets, project:docs @ ~/tests/worktrunk-fork.testbranch
worktrunk-fork ➜ : wtt config shell install
○ Already configured shell extension & completions for bash @ ~/.bashrc
○ Already configured shell extension & completions for zsh @ ~/.zshrc
○ Already configured shell extension for fish @ ~/.config/fish/functions/wtt.fish
○ Already configured completions for fish @ ~/.config/fish/completions/wtt.fish
○ Already configured shell extension for nu @ ~/.config/nushell/vendor/autoload/wtt.nu
✓ All shells already configured

for the chance you may think these are reversed in order (they weren't I just re-ran things for the comment), here's a followup switch:

worktrunk-fork ➜ : wtt switch testbranch
▲ Worktree for testbranch @ ~/tests/worktrunk-fork.testbranch, but cannot change directory — shell integration not installed

I'm running nu 0.109.1 on macOS

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants