-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: command to show env status #3725
Comments
opam 2 supports automatically changing switches as you navigate in your shell. I'm not sure where that code lives in the source tree, but it should provide a good starting point if the built-in support doesn't work for your setup. |
Indeed, at |
@rjbou Ah, yes I'm not using the hooks that opam init wants to create since I like to manage my shell config myself. But you're right that I could probably just update the env on every command. However what I really want to do is show a flag in my prompt when my opam env is out of sync. And I don't think this is possible using any existing commands? |
Usually, one easy way that covers most of the cases (not some tricky ones) is that your env is out of sync when the switch prefix doesn't match opam's one. So, a light check is to add on your prompt command something like
Shell hook files can be found in |
|
I'm always having trouble with is keeping track of when I need to run
eval $(opam env)
. For example when cd-ing between a local switches. If there was a quick way to query opam about when I needed to update my env it would be easy to write a shell plugin that automatically reconfigures the env when needed.For example a command like this would do the trick:
That returns
Env is up to date
orRun 'eval $(opam env)'
This might also be useful for dune to give a hint that you forgot to configure the env when your build fails.
Does this feature make sense? In that case I could try to put together some kind of pull request.
The text was updated successfully, but these errors were encountered: