-
Notifications
You must be signed in to change notification settings - Fork 942
[Bugfix] rbenv.p9k fails if specified local ruby version is not present #1199
base: next
Are you sure you want to change the base?
Conversation
Signed-off-by: Chris Baker <[email protected]>
I've got the |
Signed-off-by: Chris Baker <[email protected]>
Hey @ChrisBaker97 , Thanks for the contribution. Much appreciated. I made some changes to your PR. Could you verify that these fixes work for you? And would you be so kind to post the output of Thanks a lot. |
Hi @dritter, Appreciate you taking a look at this. Your changes appear to be working fine. Here's the output you requested:
Looking at this now, after a break, I realize that it could be clearer, in that I included the icon in the previously-existing variable |
Awesome 😎 ! Thanks for the quick answer and the helpful use-cases. Now that I know that there are multiple layers of ruby versions that can be active, I think about turning this segment into a stateful one. Maybe we could find the relevant state this way (warning: untested pseudo code): local -A states=( "$(echo -n 'VERSION ' && rbenv version-name 2>/dev/null || echo -n " ''" && echo -n 'LOCAL ' && rbenv local 2>/dev/null || echo -n " ''" && echo -n 'GLOBAL ' && rbenv global 2>/dev/null || echo -n " ''" )" ) Caveat: I am not sure, if local currentState
[[ -n "${states[GLOBAL]}" ]] && currentState="GLOBAL"
[[ -n "${states[LOCAL]}" ]] && currentState="LOCAL"
[[ -n "${states[VERSION]}" ]] && currentState="VERSION"
local currentVersion="${states[$currentState]}"
p9k::prepare_segment "$0" "${currentState}" $1 "$2" $3 "${currentVersion}" This is a very wild idea, so it might not work, but if it does, it might help to clear the code a bit up. And I still have some questions:
Edit: |
Sorry about the delay. I'm happy to work on this, but it could be a little bit until I have a block of time. I'll have to take a look at some of the stateful segments to get a handle on that. Tests aren't a problem—I've already gotten my head around that working on the Node segment. I can probably tackle tests first, with the current code, and then use that to help verify that a stateful mod is working properly. Addressing your questions, I think this might do a better job than I could explaining how the various layers of Ruby version specification interact. More than a shortcut, I don't really have a better name for I don't believe that With all that in mind, does it make sense to commit this PR once tests are in place, and then open up a separate issue for the stateful conversion, if you think there can be a workaround to the environment variable problem? |
I believe this should fix the same issue as #1197 in the
master
branch, but I can't actually test it, since several segments in thenext
branch are broken on my install, includingrbenv
.