Open multiple tabs in iTerm2 with a specific directoriesHow do I set up an AppleScript to open a new iTerm2...

Validation accuracy vs Testing accuracy

Should I join office cleaning event for free?

How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators?

How to re-create Edward Weson's Pepper No. 30?

Banach space and Hilbert space topology

Is the month field really deprecated?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

declaring a variable twice in IIFE

How is this relation reflexive?

How can bays and straits be determined in a procedurally generated map?

Shell script can be run only with sh command

Can I make popcorn with any corn?

Why CLRS example on residual networks does not follows its formula?

Is there really no realistic way for a skeleton monster to move around without magic?

Prevent a directory in /tmp from being deleted

What are these boxed doors outside store fronts in New York?

Is it possible to do 50 km distance without any previous training?

How to make payment on the internet without leaving a money trail?

TGV timetables / schedules?

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

What exactly is the parasitic white layer that forms after iron parts are treated with ammonia?

Compute hash value according to multiplication method

"You are your self first supporter", a more proper way to say it

How is it possible for user to changed after storage was encrypted? (on OS X, Android)



Open multiple tabs in iTerm2 with a specific directories


How do I set up an AppleScript to open a new iTerm2 tab and change the directory?Programmatically set the color of a tab in iTerm2?terminal.app: how to read the terminal window titleUse iTerm2 and Mac OSX 10.8.3 to open tabbed shells to specific systemsOpen terminal app with multiple ssh tabsName a tab in iterm2, even with pane splitsusing FISH shell — set default folder for multiple tabs?In iTerm2, can you set multiple working directories in tabs for a Profile on startup?iTerm2: Get the tab number from bash shellHow to completely disable iTerm2 pop up messagesintegrate tmux tabs with vim tabs






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







8















I would like to know if this is possible.



I want to set up some script or command that will open 5 tabs and each tab that will open will have their own directory specified



All in the same window



tab 1: open ~/folderA1
tab 2: open ~/folderA2
tab 3: open ~/folderA3
tab 4: open ~/folderA4
tab 5: open ~/folderA5


This is on iTerm2 in Mac OS X.



I know I can do something like CMD+T and then open each of them using cd ~/folderA1 and so on, but if there is a command that I can set up or a script that after executing they will do that all at once I would love to know if there is a way to do so.










share|improve this question































    8















    I would like to know if this is possible.



    I want to set up some script or command that will open 5 tabs and each tab that will open will have their own directory specified



    All in the same window



    tab 1: open ~/folderA1
    tab 2: open ~/folderA2
    tab 3: open ~/folderA3
    tab 4: open ~/folderA4
    tab 5: open ~/folderA5


    This is on iTerm2 in Mac OS X.



    I know I can do something like CMD+T and then open each of them using cd ~/folderA1 and so on, but if there is a command that I can set up or a script that after executing they will do that all at once I would love to know if there is a way to do so.










    share|improve this question



























      8












      8








      8


      1






      I would like to know if this is possible.



      I want to set up some script or command that will open 5 tabs and each tab that will open will have their own directory specified



      All in the same window



      tab 1: open ~/folderA1
      tab 2: open ~/folderA2
      tab 3: open ~/folderA3
      tab 4: open ~/folderA4
      tab 5: open ~/folderA5


      This is on iTerm2 in Mac OS X.



      I know I can do something like CMD+T and then open each of them using cd ~/folderA1 and so on, but if there is a command that I can set up or a script that after executing they will do that all at once I would love to know if there is a way to do so.










      share|improve this question
















      I would like to know if this is possible.



      I want to set up some script or command that will open 5 tabs and each tab that will open will have their own directory specified



      All in the same window



      tab 1: open ~/folderA1
      tab 2: open ~/folderA2
      tab 3: open ~/folderA3
      tab 4: open ~/folderA4
      tab 5: open ~/folderA5


      This is on iTerm2 in Mac OS X.



      I know I can do something like CMD+T and then open each of them using cd ~/folderA1 and so on, but if there is a command that I can set up or a script that after executing they will do that all at once I would love to know if there is a way to do so.







      macos bash iterm2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      Ali

















      asked Jun 8 '13 at 20:02









      AliAli

      71451731




      71451731






















          1 Answer
          1






          active

          oldest

          votes


















          8














          Update: Newer iTerm requires you to change the syntax, so this would look like:



          tell application "iTerm"
          tell current window
          create tab with default profile
          end tell
          tell current tab of current window
          set _new_session to last item of sessions
          end tell
          tell _new_session
          select
          write text "cd "$dir""
          end tell
          end tell


          See also this answer here.





          For older iTerm versions:



          Taking the script from my answer here, you can do something like this:



          launch () {
          for dir in ~/folderA{1..5}; do
          /usr/bin/osascript <<-EOF
          tell application "iTerm"
          make new terminal
          tell the current terminal
          activate current session
          launch session "Default Session"
          tell the last session
          write text "cd "$dir""
          end tell
          end tell
          end tell
          EOF
          done
          }


          To explain what's going on:




          • We create a shell function named launch, so you can put this in your ~/.bash_profile or wherever you want to have it executed at startup.


          • We loop over the result of the Bash brace expansion ~/folderA{1..5}, which gives you ~/folderA1 through ~/folderA5.


          • We call the iTerm2 AppleScript library through osascript to create a new tab, activate it, launch the default session, and cd to the specified directory.







          share|improve this answer


























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f605390%2fopen-multiple-tabs-in-iterm2-with-a-specific-directories%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            8














            Update: Newer iTerm requires you to change the syntax, so this would look like:



            tell application "iTerm"
            tell current window
            create tab with default profile
            end tell
            tell current tab of current window
            set _new_session to last item of sessions
            end tell
            tell _new_session
            select
            write text "cd "$dir""
            end tell
            end tell


            See also this answer here.





            For older iTerm versions:



            Taking the script from my answer here, you can do something like this:



            launch () {
            for dir in ~/folderA{1..5}; do
            /usr/bin/osascript <<-EOF
            tell application "iTerm"
            make new terminal
            tell the current terminal
            activate current session
            launch session "Default Session"
            tell the last session
            write text "cd "$dir""
            end tell
            end tell
            end tell
            EOF
            done
            }


            To explain what's going on:




            • We create a shell function named launch, so you can put this in your ~/.bash_profile or wherever you want to have it executed at startup.


            • We loop over the result of the Bash brace expansion ~/folderA{1..5}, which gives you ~/folderA1 through ~/folderA5.


            • We call the iTerm2 AppleScript library through osascript to create a new tab, activate it, launch the default session, and cd to the specified directory.







            share|improve this answer






























              8














              Update: Newer iTerm requires you to change the syntax, so this would look like:



              tell application "iTerm"
              tell current window
              create tab with default profile
              end tell
              tell current tab of current window
              set _new_session to last item of sessions
              end tell
              tell _new_session
              select
              write text "cd "$dir""
              end tell
              end tell


              See also this answer here.





              For older iTerm versions:



              Taking the script from my answer here, you can do something like this:



              launch () {
              for dir in ~/folderA{1..5}; do
              /usr/bin/osascript <<-EOF
              tell application "iTerm"
              make new terminal
              tell the current terminal
              activate current session
              launch session "Default Session"
              tell the last session
              write text "cd "$dir""
              end tell
              end tell
              end tell
              EOF
              done
              }


              To explain what's going on:




              • We create a shell function named launch, so you can put this in your ~/.bash_profile or wherever you want to have it executed at startup.


              • We loop over the result of the Bash brace expansion ~/folderA{1..5}, which gives you ~/folderA1 through ~/folderA5.


              • We call the iTerm2 AppleScript library through osascript to create a new tab, activate it, launch the default session, and cd to the specified directory.







              share|improve this answer




























                8












                8








                8







                Update: Newer iTerm requires you to change the syntax, so this would look like:



                tell application "iTerm"
                tell current window
                create tab with default profile
                end tell
                tell current tab of current window
                set _new_session to last item of sessions
                end tell
                tell _new_session
                select
                write text "cd "$dir""
                end tell
                end tell


                See also this answer here.





                For older iTerm versions:



                Taking the script from my answer here, you can do something like this:



                launch () {
                for dir in ~/folderA{1..5}; do
                /usr/bin/osascript <<-EOF
                tell application "iTerm"
                make new terminal
                tell the current terminal
                activate current session
                launch session "Default Session"
                tell the last session
                write text "cd "$dir""
                end tell
                end tell
                end tell
                EOF
                done
                }


                To explain what's going on:




                • We create a shell function named launch, so you can put this in your ~/.bash_profile or wherever you want to have it executed at startup.


                • We loop over the result of the Bash brace expansion ~/folderA{1..5}, which gives you ~/folderA1 through ~/folderA5.


                • We call the iTerm2 AppleScript library through osascript to create a new tab, activate it, launch the default session, and cd to the specified directory.







                share|improve this answer















                Update: Newer iTerm requires you to change the syntax, so this would look like:



                tell application "iTerm"
                tell current window
                create tab with default profile
                end tell
                tell current tab of current window
                set _new_session to last item of sessions
                end tell
                tell _new_session
                select
                write text "cd "$dir""
                end tell
                end tell


                See also this answer here.





                For older iTerm versions:



                Taking the script from my answer here, you can do something like this:



                launch () {
                for dir in ~/folderA{1..5}; do
                /usr/bin/osascript <<-EOF
                tell application "iTerm"
                make new terminal
                tell the current terminal
                activate current session
                launch session "Default Session"
                tell the last session
                write text "cd "$dir""
                end tell
                end tell
                end tell
                EOF
                done
                }


                To explain what's going on:




                • We create a shell function named launch, so you can put this in your ~/.bash_profile or wherever you want to have it executed at startup.


                • We loop over the result of the Bash brace expansion ~/folderA{1..5}, which gives you ~/folderA1 through ~/folderA5.


                • We call the iTerm2 AppleScript library through osascript to create a new tab, activate it, launch the default session, and cd to the specified directory.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 13 '18 at 11:42

























                answered Jun 8 '13 at 21:57









                slhckslhck

                163k47450475




                163k47450475






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f605390%2fopen-multiple-tabs-in-iterm2-with-a-specific-directories%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

                    Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

                    VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...