Hello,
Hopefully this is the correct forum for this question, if not please accept my 
apology.

I am trying to write a bash script to:

*         Start tmux and create a window

*         Split the window into 4 panes

*         In each pane 'cd' to the specified directory and list files

Everything works except the changing of directories although the change 
directory on line 15 does work.
I have implemented this basic idea using tmux windows but I thought that panes 
would be a more usable solution.
When I exit the session an error is show on the command line that path used for 
the 'cd' does not exist. It does exist if I try it from the command line which 
leads me to believe its got something to do with the way I am trying to reach 
from inside the pane.
I've poked around on some forums and have seen references to 'send-keys' in 
which commands like 'tail' are used, but that does not seem to work for the 
'cd' command.
I don't see anything in the man page about needing to treat shell commands in 
the panes differently.
The 'cd' commands work as expected if I execute them manually once the panes 
are created by the script.

Any help would be appreciated.
Thanks
Steven Wright


  1 WINDOW=ambassador
  2 SESSION=$USER
  3 WORKING_DIR=~/workspace/gti-ambassador-0.2.0
  4
  5  # if the session is already running, just attach to it.
  6 tmux has-session -t $SESSION
  7 if [ $? -eq 0 ]; then
  8      echo "Session $SESSION already exists. Attaching."
  9      sleep 1
10      tmux attach -t $SESSION
11      exit 0;
12 fi
13
14 # CD to the working directory
15 cd $WORKING_DIR
16
17  # create a new session, named $SESSION, and detach from it
18 tmux new-session -d -s $SESSION
19  # Set defaults
20 tmux set-window-option  -t $SESSION -g automatic-rename off
21
22 # Setup the panes that I want
23 # Create the parent window
24 tmux new-window  -t $SESSION:0 -k -n $WINDOW
25 # Split it into two columns
26 tmux split-window -h
27 # Select the first pane
28 tmux select-pane -t 0
29 # Split it into two rows
30 tmux split-window -v
31 # Select the right column
32 tmux select-pane -t 2
33 # Split it into two rows
34 tmux split-window -v
35
36 # Set up the Application pane
37 tmux select-pane -t 0
38 cd $WORKING_DIR/source/bin
39 ll
40
41 # Setup the Logging Pane
42 tmux select-pane -t 1
43 cd $WORKING_DIR/source/bin/logs
44
45 # Setup the SQR  Pane
46 tmux select-pane -t 2
47 cd $WORKING_DIR/source/utils
48
49 # Setup the Test  Pane
50 tmux select-pane -t 3
51 cd $WORKING_DIR/source/bin/logs
52
53 # all done. select starting window and get to work
54 tmux attach -t $SESSION
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to