Run component processes in the user's shell context
daneah opened this issue · comments
I can't figure out how to get components to run in the context of the current shell, which means things like pyenv
and rvm
don't work since they require loading. The WIP components work when run manually in a virtualenv, but not when placed in the AutoLaunch
folder.
So, I haven't exactly solved this issue, but I think I might have some pointers for the pyenv and rvm components.
If you look at george's title algorithm he uses shell integration to provide user variables in the context of the current shell. I couldn't find any documentation on this but something like this might get you further with these components:
in bashrc/zshrc/etc
function iterm2_print_user_vars() {
iterm2_set_user_var pyenvVersion $(pyenv local)
iterm2_set_user_var rvmGemset $(rvm-prompt g)
}
in the component script
pyenv_version = iterm2.Reference("user.pyenvVersion?")
rvm_gemset = iterm2.Reference("user.rvmGemset?")
I'm not exactly sure how often the shell integration runs iterm2_print_user_vars
so idk how to handle updating those variables (if you change your python version or whatnot) but I think this should at least get you somewhere. I don't have pyenv or rvm installed so I haven't messed around with the actual components themselves, but I just thought I'd share my research here
Thanks @harrygallagher4! The example you link to is quite helpful; I don't think I saw that one when I was initially trying this out. I'll see what can be done in this area!