Skip to content

Auto-reload shell environment instead of requiring Ctrl-Alt-R#2658

Merged
domenkozar merged 3 commits intomainfrom
auto-reload-shell
Apr 8, 2026
Merged

Auto-reload shell environment instead of requiring Ctrl-Alt-R#2658
domenkozar merged 3 commits intomainfrom
auto-reload-shell

Conversation

@domenkozar
Copy link
Copy Markdown
Member

Summary

  • Shell environment now auto-reloads at the next prompt via PROMPT_COMMAND instead of requiring the user to press Ctrl-Alt-R
  • Status bar shows "reloaded" after the environment is applied, instead of prompting with a keybind hint
  • Ctrl-Alt-R keybind still works for immediate reload, just no longer advertised

Fixes #2595.

Test plan

  • Run devenv shell, edit devenv.nix, verify environment reloads automatically at next prompt
  • Verify status bar shows "building..." then "ready" then "reloaded" transitions
  • Verify Ctrl-Alt-R still works for immediate reload
  • cargo nextest run -p devenv-shell passes (131 tests, snapshot updated)

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 24, 2026

🔍 Suggested Reviewers

Based on git blame analysis of the changed lines, the following contributors have significant experience with the modified code:

  • @sandydoo - 100.0% of changed lines (3 lines)

Please consider reviewing this PR as you have authored significant portions of the code being modified. Your expertise would be valuable! 🙏

This comment was automatically generated by git-blame-auto-reviewer

Last updated: 2026-04-08T08:51:25.421Z

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 24, 2026

Deploying devenv with  Cloudflare Pages  Cloudflare Pages

Latest commit: a8ccb67
Status: ✅  Deploy successful!
Preview URL: https://10a94b2b.devenv.pages.dev
Branch Preview URL: https://auto-reload-shell.devenv.pages.dev

View logs

@AmentumStudio
Copy link
Copy Markdown

AmentumStudio commented Mar 24, 2026

Changing .name in devenv.nix triggers rebuild, but one needs to exit shell and enter shell again to see changes.
(I see ready, but never reloaded).

EDIT: This happens with https://github.com/mcdonc/devenv-zsh turned on (it actually does use zsh with devenv shell v2 now).

@AmentumStudio
Copy link
Copy Markdown

AmentumStudio commented Mar 24, 2026

Adding random package:
packages = [ pkgs.gost ];
Triggers rebuild, there is ready, never reloaded, which gost results in gost not found.
I need to exit shell and run nix run github:cachix/devenv/auto-reload-shell shell for which gost to return the path.

EDIT: This happens with https://github.com/mcdonc/devenv-zsh turned on (it actually does use zsh with devenv shell v2 now).

@AmentumStudio
Copy link
Copy Markdown

If I don't use devenv-zsh (and use bash as result), I need to press ENTER once there appears ready in the bottom of TUI, then it changes to reloaded.
But once it is rebuilt and relodaded, changing anything else in devenv.nix does not trigger any rebuilds.
It behaves as if it only listens for first change, then stops listenging.

@euphemism
Copy link
Copy Markdown

Is it possible to support both auto-reload and manual triggering? i.e. introducing a config option for the manual keybind?

@domenkozar
Copy link
Copy Markdown
Member Author

Is it possible to support both auto-reload and manual triggering? i.e. introducing a config option for the manual keybind?

You'd prefer manual reload?

@euphemism
Copy link
Copy Markdown

Is it possible to support both auto-reload and manual triggering? i.e. introducing a config option for the manual keybind?

You'd prefer manual reload?

In some scenarios, possibly. My main issue is that as currently implemented I simply can't use the feature.

@domenkozar
Copy link
Copy Markdown
Member Author

Changing .name in devenv.nix triggers rebuild, but one needs to exit shell and enter shell again to see changes. (I see ready, but never reloaded).

EDIT: This happens with https://github.com/mcdonc/devenv-zsh turned on (it actually does use zsh with devenv shell v2 now).

It should reload if you press enter. Can you try again?

domenkozar and others added 3 commits April 8, 2026 04:13
…l-Alt-R

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Editors using atomic save (write temp + rename) replace the file inode,
which silently invalidates the kernel inotify watch. The watchexec fs
worker skips re-watching paths already in its pathset, so the stale
watch is never refreshed and subsequent edits go undetected.

Add WatcherHandle::rewatch_all() that forces a full refresh by clearing
and re-setting the pathset, and call it after each reload build completes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@domenkozar
Copy link
Copy Markdown
Member Author

I've tested and this works now, addressing the issue of manually reloading the shell. We can still introduce possibility to bind it to a key later on, as this matches how direnv worked.

@domenkozar domenkozar merged commit 02285f5 into main Apr 8, 2026
16 checks passed
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.

Unable to trigger shell reload using Ctrl+Alt-R combination on MacOS

3 participants