How can I launch a new session of tmux in iTerm2 on a separate window?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I would like to start a tmux session on a separate window in iTerm2. Now I'm writing my own configuration script to launch the session.



tmux new-session -s dev -n main -d
tmux send-keys -t dev "cd $DL" C-m
tmux split-window -h -t dev
tmux split-window -v -t dev -p 30
tmux resize-pane -x 70 -y 20
tmux attach -t dev


This starts a new session but the window is on the window I execute the script, not the new, separate window in iTerm2.



So I changed the first line (tmux new-session -s dev -n main -d) to tmux -CC new -t dev, but then although the session starts in a new window, it does not have the split and the resize. It seems to only open the new session in a new window and that's all.



How can I make it launched in a new window with all the initial settings including the directory change, split window, etc...?







share|improve this question























    up vote
    0
    down vote

    favorite












    I would like to start a tmux session on a separate window in iTerm2. Now I'm writing my own configuration script to launch the session.



    tmux new-session -s dev -n main -d
    tmux send-keys -t dev "cd $DL" C-m
    tmux split-window -h -t dev
    tmux split-window -v -t dev -p 30
    tmux resize-pane -x 70 -y 20
    tmux attach -t dev


    This starts a new session but the window is on the window I execute the script, not the new, separate window in iTerm2.



    So I changed the first line (tmux new-session -s dev -n main -d) to tmux -CC new -t dev, but then although the session starts in a new window, it does not have the split and the resize. It seems to only open the new session in a new window and that's all.



    How can I make it launched in a new window with all the initial settings including the directory change, split window, etc...?







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I would like to start a tmux session on a separate window in iTerm2. Now I'm writing my own configuration script to launch the session.



      tmux new-session -s dev -n main -d
      tmux send-keys -t dev "cd $DL" C-m
      tmux split-window -h -t dev
      tmux split-window -v -t dev -p 30
      tmux resize-pane -x 70 -y 20
      tmux attach -t dev


      This starts a new session but the window is on the window I execute the script, not the new, separate window in iTerm2.



      So I changed the first line (tmux new-session -s dev -n main -d) to tmux -CC new -t dev, but then although the session starts in a new window, it does not have the split and the resize. It seems to only open the new session in a new window and that's all.



      How can I make it launched in a new window with all the initial settings including the directory change, split window, etc...?







      share|improve this question











      I would like to start a tmux session on a separate window in iTerm2. Now I'm writing my own configuration script to launch the session.



      tmux new-session -s dev -n main -d
      tmux send-keys -t dev "cd $DL" C-m
      tmux split-window -h -t dev
      tmux split-window -v -t dev -p 30
      tmux resize-pane -x 70 -y 20
      tmux attach -t dev


      This starts a new session but the window is on the window I execute the script, not the new, separate window in iTerm2.



      So I changed the first line (tmux new-session -s dev -n main -d) to tmux -CC new -t dev, but then although the session starts in a new window, it does not have the split and the resize. It seems to only open the new session in a new window and that's all.



      How can I make it launched in a new window with all the initial settings including the directory change, split window, etc...?









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jul 4 at 20:51









      Blaszard

      121117




      121117




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You can use applescript to do something like this:



          $ cat a.bash
          #!/bin/bash
          osascript - "$@" <<EOF
          on run argv
          tell application "iTerm"
          activate
          set new_term to (create window with default profile)
          tell new_term
          tell the current session
          repeat with arg in argv
          write text arg
          end repeat
          end tell
          end tell
          end tell
          end run
          EOF


          This provides a script which can then pass arguments passed into it, into another iterm2 terminal.



          For example:



          $ ./a.bash "echo 'hello iterm2'"


             ss of iterm2 launch



          References



          • https://stackoverflow.com/questions/32675804/how-do-i-execute-a-command-in-an-iterm-window-from-the-command-line





          share|improve this answer





















          • Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
            – Blaszard
            Jul 5 at 11:26










          • @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
            – slm♦
            Jul 5 at 13:55











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453499%2fhow-can-i-launch-a-new-session-of-tmux-in-iterm2-on-a-separate-window%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You can use applescript to do something like this:



          $ cat a.bash
          #!/bin/bash
          osascript - "$@" <<EOF
          on run argv
          tell application "iTerm"
          activate
          set new_term to (create window with default profile)
          tell new_term
          tell the current session
          repeat with arg in argv
          write text arg
          end repeat
          end tell
          end tell
          end tell
          end run
          EOF


          This provides a script which can then pass arguments passed into it, into another iterm2 terminal.



          For example:



          $ ./a.bash "echo 'hello iterm2'"


             ss of iterm2 launch



          References



          • https://stackoverflow.com/questions/32675804/how-do-i-execute-a-command-in-an-iterm-window-from-the-command-line





          share|improve this answer





















          • Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
            – Blaszard
            Jul 5 at 11:26










          • @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
            – slm♦
            Jul 5 at 13:55















          up vote
          0
          down vote













          You can use applescript to do something like this:



          $ cat a.bash
          #!/bin/bash
          osascript - "$@" <<EOF
          on run argv
          tell application "iTerm"
          activate
          set new_term to (create window with default profile)
          tell new_term
          tell the current session
          repeat with arg in argv
          write text arg
          end repeat
          end tell
          end tell
          end tell
          end run
          EOF


          This provides a script which can then pass arguments passed into it, into another iterm2 terminal.



          For example:



          $ ./a.bash "echo 'hello iterm2'"


             ss of iterm2 launch



          References



          • https://stackoverflow.com/questions/32675804/how-do-i-execute-a-command-in-an-iterm-window-from-the-command-line





          share|improve this answer





















          • Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
            – Blaszard
            Jul 5 at 11:26










          • @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
            – slm♦
            Jul 5 at 13:55













          up vote
          0
          down vote










          up vote
          0
          down vote









          You can use applescript to do something like this:



          $ cat a.bash
          #!/bin/bash
          osascript - "$@" <<EOF
          on run argv
          tell application "iTerm"
          activate
          set new_term to (create window with default profile)
          tell new_term
          tell the current session
          repeat with arg in argv
          write text arg
          end repeat
          end tell
          end tell
          end tell
          end run
          EOF


          This provides a script which can then pass arguments passed into it, into another iterm2 terminal.



          For example:



          $ ./a.bash "echo 'hello iterm2'"


             ss of iterm2 launch



          References



          • https://stackoverflow.com/questions/32675804/how-do-i-execute-a-command-in-an-iterm-window-from-the-command-line





          share|improve this answer













          You can use applescript to do something like this:



          $ cat a.bash
          #!/bin/bash
          osascript - "$@" <<EOF
          on run argv
          tell application "iTerm"
          activate
          set new_term to (create window with default profile)
          tell new_term
          tell the current session
          repeat with arg in argv
          write text arg
          end repeat
          end tell
          end tell
          end tell
          end run
          EOF


          This provides a script which can then pass arguments passed into it, into another iterm2 terminal.



          For example:



          $ ./a.bash "echo 'hello iterm2'"


             ss of iterm2 launch



          References



          • https://stackoverflow.com/questions/32675804/how-do-i-execute-a-command-in-an-iterm-window-from-the-command-line






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jul 4 at 23:12









          slm♦

          233k65479651




          233k65479651











          • Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
            – Blaszard
            Jul 5 at 11:26










          • @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
            – slm♦
            Jul 5 at 13:55

















          • Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
            – Blaszard
            Jul 5 at 11:26










          • @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
            – slm♦
            Jul 5 at 13:55
















          Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
          – Blaszard
          Jul 5 at 11:26




          Thanks but how can I take the script to the argument of the a.bash? ./a.bash < my_script does not work (it only launches the window). It works if it is ./a.bash "tmux new -s dev", though.
          – Blaszard
          Jul 5 at 11:26












          @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
          – slm♦
          Jul 5 at 13:55





          @Blaszard - can you please update your question, it's not clear what exactly you want/expect to happen here then.If the last part works I'd saw your problem's solved, which I know isn't the case in your mind, but we need more to go on then.
          – slm♦
          Jul 5 at 13:55













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453499%2fhow-can-i-launch-a-new-session-of-tmux-in-iterm2-on-a-separate-window%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay