I use the following tmux code in a script file tmux-dev.sh and add it to bash using bash /home/rohit/tmux-dev.sh :tmux new-session -dtmux split-window -htmux split-window -vtmux -2 attach-session -dThe script causes a nesting of tmux panes giving error: pane too small.To my surprise , the same bash tmux-dev.sh when put into the title and command box of gnome-terminal it works perfectly fine and gives this screenPlease help me out with this.I am using ubuntu 14.10.P.S-- Please stay away from suggesting any tools , I am here for an explanation for this behavior and raw shell script solution.
Running script through bashrc causes nesting of tmux panes
bash;ubuntu;terminal;tmux;bashrc
As @fiximan suggested , I tried to test if tmux session exists or not and then execute some code and finally, with a little tweak I am successful in getting the layout I wanted. Here is what I added to my .bashrc :test -z $TMUX && (tmux new-session -d && tmux split-window -h && tmux split-window -v && tmux -2 attach-session -d)I will break down the above for an explanation:test -z $TMUX -> This tests whether there is already a tmux session running or not , thus, preventing nesting of tmux sessionstmux new-session -d -> Creates a new sessiontmux split-window -h -> Splits the window verticallytmux split-window -v -> Splits the window horizontallytmux -2 attach-session -d-> Attaches the sessionsNOTE-- I have used && operator not the || operator because the later would short-circuit.