chruby
chruby copied to clipboard
Is there a way to get chruby to automatically do something when switching?
I have a ruby 1.8 install where I must set RUBYLIB manually before any ruby programs will work ... is it possible to have chruby do this automatically when switching to ruby 1.8? I don't see a way ... it would be nice to be able to take arbitrary actions when switching rubies ...
You would have to write your own post-switching commands system.
Or use one of the zillions that already exist... Here are some notes from a year ago when I needed to solve this. (I ended up writing a one-off script, eschew overengineering)
- autoenv: Overrides cd, that won't go well.
- direnv: Well that's an awful lot of Go code.
- anyenv: No README, looks kinda loose on security.
- dotenv: Ruby/Rails-specific, requires changing your source code.
- chenv: A lot of code plus a git-style UI. It's a popular name: chenv, chenv, etc.
- aam: Apparently it's now named tem.
- tem: Must be solving a completely different problem?
@bronson right, the real problem is Bash doesn't support something like preexec_functions. You have to either inject a command into PROMPT_COMMAND (only works in interactive mode) or use trap DEBUG (not inherited by sub-processes). So most of these Bash solutions clobber any previously inserted Bash "hooks".
Would the idea proposed in #227 make this easier?
@ilikepi providing a function would allow users to manually set the trap DEBUG command. Manually injection into trap DEBUG is still impossibly/difficult unless set -T is set.
Right... so does that mean you agree with this proposal (in a general sense)? I'm happy to put together a PR for further discussion.
On Jan 5, 2016, at 20:33, Postmodern [email protected] wrote:
@ilikepi providing a function would allow users to manually set the trap DEBUG command. Manually injection into trap DEBUG is still impossibly/difficult unless set -T is set.
— Reply to this email directly or view it on GitHub.
rbenv has plugins that enable you to do things when switching versions and other things. Would love to see that in chruby, too.