Creating a new tmux session from within a session
<p>I am using a voice assistant on my RPi, but because of a certain tmux session I have, it won't work.</p>

<p>That is fine, because I came up with an idea to fix this.</p>

<p>Since my voice assistant is written in Python, I thought I could use the <code>os</code> module to do a <code>os.system('tmux kill-session -t Radio')</code>.</p>

<p>This works fine, but when I tried to create the session the session again, using <code>tmux new-session -d -s Radio 'python blah blah'</code>, it doesn't work, because I am trying to create a tmux session from within another.</p>

<p>Upon google, I found various suggestions, all of which didn't really fit my need (nor could be adapted).</p>

<p>What command could I execute from within Python from within a Tmux session, that could create a new tmux session, name it, and auto enter a command, but not be tied to the current session (Meaning I wouldn't have to attach to the voice assistant session to attach to the other one)</p>

<p>You'll need to unset the TMUX environment variable</p>

<pre><code># assuming this is the shell inside tmux
$ export TMUX=
# now you can run tmux inside tmux    
$ tmux
</code></pre>

<p>So the important line is <code>export TMUX=</code> prior to the inception of tmux.</p>

python raspberry-pi tmux