Have tmux windows inherit `activate`d anaconda environment

拜拜、爱过 提交于 2019-12-12 11:56:54

问题


For convenience and given that activate-ing an environment is crazy slow, I want to activate an environment and then start a tmux session.

I want all new tmux windows to also have the environment activated.

I want different tmux sessions to be able to support different anaconda environments.

How do I go about this?

Are there any gotchas such that this isn't supported by anaconda / miniconda?


回答1:


What I've done to address this problem is:

  • In .tmux.conf, copy CONDA_DEFAULT_ENV environment variable to session environment
    set-option -ga update-environment 'CONDA_DEFAULT_ENV'
    
  • In .bashrc, reactivate the conda environment if one was activated:
    if [ -n "$CONDA_DEFAULT_ENV" ]; then                                                                                                                                         
        __conda_reactivate                                                                                                                                                       
    fi
    
    Note 1: this assumes that __conda_reactivate is available because of conda init or similar. Note 2: in older versions of conda, it's _conda_reactivate (just one leading underscore).

This is faster than conda activate <env> and also different environments can be used before creating different tmux sessions.



来源:https://stackoverflow.com/questions/55913834/have-tmux-windows-inherit-activated-anaconda-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!