tmux使用当前激活的conda环境创建新的窗格或窗口 [英] tmux create new pane or window with current activated conda environment
问题描述
当我使用tmux创建新窗格或窗口时,我想使用刚才使用的相同conda环境.
即我现在正在使用名为 XXXenv
的conda env,并使用 Ctrl + b
+ %
创建一个新窗格,我想要的是新创建的窗格由conda env XXXenv
激活.
事实上,我已经尝试过
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.
Heyo, there's likely an environment var called CONDA_DEFAULT_ENV within your shell. Create a bash script that defines the layout you want and use this var to send the original pane's currently active environment to all the new panes.
dev-sesh.sh:
#!/bin/sh
current_session=$(tmux display-message -p '#S')
current_conda=$CONDA_DEFAULT_ENV
tmux split-window -v -p 75 -b
tmux split-window -h -p 50
tmux send-keys -t "$current_session.{left}" "conda activate $current_conda" 'Enter'
tmux send-keys -t "$current_session.{right}" "conda activate $current_conda" 'Enter'
tmux send-keys -t "$current_session.{left}" "clear && figlet Welcome" 'Enter'
tmux send-keys -t "$current_session.{right}" "clear" 'Enter'
tmux send-keys -t "$current_session.{bottom}" "clear" 'Enter'
tmux.conf:
bind -n C-n send-keys 'bash ~/.dotfiles/dev-sesh.sh' Enter
result:
这篇关于tmux使用当前激活的conda环境创建新的窗格或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!