Have tmux windows inherit `activate`d anaconda environment

后端 未结 1 401
眼角桃花
眼角桃花 2021-01-20 03:28

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 ne

相关标签:
1条回答
  • 2021-01-20 04:17

    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.

    0 讨论(0)
提交回复
热议问题