Reputation: 219
I have written a shell script which should ideally create a tmux session and activate virtual environment in it. But it does not activate it after creating tmux session. Here is the code snippet:
cd /home
cd Portals/
tmux new-session -d -s devgeo
source activate.sh
And this is my activate.sh file
source "venv/bin/activate"
What am I doing wrong. Can anyone help me out?
Upvotes: 1
Views: 1195
Reputation: 532093
You are executing source activate.sh
in your current shell, not in the shell running in your newly created tmux
session. Use the send-keys
command to send that command to the shell, as if you had typed it yourself.
tmux new-session -c /home/Portals -d -s devgeo
tmux send-keys -t devgeo:1 "source activate.sh" C-m
(The -c
option lets you set the working directory of the new session without having to change the working directory of your current shell.)
Upvotes: 3