Issue
I have this +x script
~/bin/tmux-test.sh
:
#!/usr/bin/bash
tmux neww
bind -n M-g run-shell `~/bin/tmux-test.sh`
It works...
...but if I change tmux neww
to tmux new
(for creating a new session) then when I press the keybind tmux shows this error on screen :
'/home/me/bin/tmux-test.sh' returned 1
What am I doing wrong?
Solution
First, tmux does not support `..`
style quoting.
And by default tmux new
(not :new
) would refuse to create new session if you are already in tmux:
$ echo $TMUX
/private/tmp/tmux-502/default,2554,0
$ tmux new
sessions should be nested with care, unset $TMUX to force
You can use tmux new -d
to create a detached session and then switch to it.
~/bin/tmux-test.sh
tmux new -d -s foo
tmux switch-client -t foo
true
tmux.conf
bind -n M-g run-shell ~/bin/tmux-test.sh
Answered By - pynexj Answer Checked By - Clifford M. (WPSolving Volunteer)