Running tmux sessions inside tilix terminal emulator
1
vote
2
answers
1182
views
**Background**: I use Tilix as my main terminal emulator. In the Tilix preferences (attached screenshot), I have set it up so that when Tilix is launched, it will run this command:
This checks:
- if a tmux session named
/usr/bin/zsh -c "if [[ $(tmux ls 2>/dev/null | grep -q -E '^main.*attached.*'; echo $?) -ne 0 ]]; then tmux attach -t main || tmux new -s main; else /usr/bin/zsh; fi"

main
is running and a window is attached to it
- If it fails, it will then try to attach to the tmux session named main
- If that fails, then it will go ahead and create a new tmux session named main
and attach to it
- Else (If successful), just launch plain zsh
The reason for all this complexity so that when I launch tilix for the first time, it will launch it with tmux running and connected to it. Any **new tilix session** or **new tilix window** lauched will not create or try to connect to the existing tmux session named main. (Tilix has its own multi window and pane which is not to be confused with tmux sessions)
What I would like to know if it is possible to condense the codeblock above, or if it is possible to come up with a better version of the codeblock above.
Asked by GMaster
(6837 rep)
May 8, 2020, 03:10 AM
Last activity: May 8, 2020, 08:11 AM
Last activity: May 8, 2020, 08:11 AM