conda - tmux create new pane or window with current activated conda environment
问题描述
When I create a new pane or window using tmux, I'd like to use the same conda environement I was just using.
I.e. I'm now using a conda env named XXXenv
, and I use Ctrl+b
+ %
to create a new pane, what I want is the new created pane is activated by the conda env XXXenv
.
In fact, I have tried Have tmux windows inherit activate
d anaconda environment, but it doesn't work for me.
解决方案
嘿嘿,有一个名为 CONDA_DEFAULT_ENV 的环境变量。创建一个定义窗格布局的 bash 脚本,并使用此 var 将原始窗格的活动 conda 环境发送到任何新窗格。然后通过一些 tmux 快捷方式调用它。
开发-sesh.sh:
#!/bin/sh
current_session=$(tmux display-message -p '#S')
current_conda=$CONDA_DEFAULT_ENV
tmux split-window -v -p 75 -b
tmux select-pane -t 1
tmux split-window -h -p 50
tmux send-keys -t "$current_session.0" "conda activate $current_conda" 'Enter';
tmux send-keys -t "$current_session.1" "conda activate $current_conda" 'Enter';
tmux send-keys -t "$current_session.2" "conda activate $current_conda" 'Enter';
tmux send-keys -t "$current_session.0" "clear && figlet Welcome" 'Enter';
tmux send-keys -t "$current_session.1" "clear" 'Enter';
tmux send-keys -t "$current_session.2" "clear" 'Enter';
tmux rename-window "dev";
tmux.conf:
bind -n C-n send-keys 'bash ~/.dotfiles/dev-sesh.sh' Enter
推荐阅读
- android - 拨号时没有 FCM 诊断 *#*#426#*#*
- spring-boot - 参数化 build.gradle 后,“gradle test”停止工作
- ldap - 尝试将用户添加到 LDAP 时收到无效凭据 (49)
- firebase - Firestore如何结合“AND”逻辑执行多个“OR”查询?
- python - 将一个数组连接到另一个数组中?
- django - 如何使用 Django 加入带有外部 API 的表?
- java - 线程“主”java.util.NoSuchElementException errorr 中的异常
- go - 尝试:除了:通过但在 Go 中?(当出现网络问题时让 Go 不会崩溃?)
- javascript - 在 Django 中从后端到前端操作和传递 JSON
- laravel - 使用 Dropbox 驱动程序无法从 Laravel 上传到 Dropbox