{"id":96,"date":"2013-06-16T09:20:54","date_gmt":"2013-06-16T09:20:54","guid":{"rendered":"http:\/\/ramandv.com\/blog\/?p=96"},"modified":"2014-06-18T06:56:07","modified_gmt":"2014-06-18T06:56:07","slug":"iterm2-applescript-opening-iterm2-with-multiple-tabs","status":"publish","type":"post","link":"http:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/","title":{"rendered":"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs"},"content":{"rendered":"\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"e9e85ee105af8a6a4a383deebf1fa216\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-4917982260456644\";\r\n\/* ramandv.com-ad1 *\/\r\ngoogle_ad_slot = \"9226290554\";\r\ngoogle_ad_width = 728;\r\ngoogle_ad_height = 90;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n<p>I always open multiple tab to launch server, mysql shell, ipython shell etc. Every time, setting the virtualenv etc in the shell and start server etc is a pain, which resulted in the following iterm2 applescript.<\/p>\n<p>The following iterm2 applescript helps to launch the multiple tabs in iterm2 . And you can name the tabs. In addition to that, You can launch the tab with some start commands too.<\/p>\n<pre><code>tell application \"iTerm\"\n    activate\n    set startCmdList to {\"renametab 'tab1' &amp;&amp; ls -l\", \"renametab 'tab2' &amp;&amp; ls\"} as list\n        -- probably you can add default commands to be executed\n    set defaultcmd to \"cd ~ &amp;&amp;\"\n    -- Create a new terminal window...\n    set myterm to (make new terminal)\n\n    tell myterm\n        set number of columns to 150\n        set number of rows to 30\n\n        repeat with cmd in startCmdList\n            launch session \"Default\"\n            tell current session\n                write text defaultcmd &amp; cmd\n                --set name to cmd\n            end tell\n        end repeat\n    end tell\n\nend tell\n<\/code><\/pre>\n<p><strong>iterm2 &#8220;renametab&#8221; alias:<\/strong><\/p>\n<p>Add the following snippet in your ~\/.bash_profile file. It add the function to rename your tab.<\/p>\n<pre><code>function renametab () {\n    echo -ne \"\\033]0;\"$@\"\\007\"\n}\n<\/code><\/pre>\n<p>If the renaming tab does not work, check whether your .bash_profile modifies the PS1 variable. You might need to comment out the following snippet.<\/p>\n<pre><code>#case \"$TERM\" in\n#xterm*|rxvt*)\n#    PS1=\"\\[\\e]0;${debian_chroot:+($debian_chroot)}\\u@\\h: \\w\\a\\]$PS1\"\n#    ;;\n#*)\n#    ;;\n#esac\n<\/code><\/pre>\n<p><strong>Installing the iterm2 applescript as an application<\/strong><\/p>\n<ul>\n<li>Open &#8220;AppleScript Editor&#8221; (\/Applications\/Utilities)<\/li>\n<li>In a new document, paste the AppleScript code from the above snippet<\/li>\n<li>Change the icon by opening bundle contents, and replacing with new applet.icns<\/li>\n<li>Export the script to \/Applications\/Utilities, use the file format &#8220;Application&#8221; (do not select &#8220;run only&#8221; if you want to be able to change the script later on)<\/li>\n<\/ul>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>I always open multiple tab to launch server, mysql shell, ipython shell etc. Every time, setting the virtualenv etc in the shell and start server etc is a pain, which resulted in the following iterm2 applescript. The following iterm2 applescript &hellip; <a href=\"http:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[21],"tags":[10],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs  - Articles for Developers\" \/>\n<meta property=\"og:description\" content=\"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/\" \/>\n<meta property=\"og:site_name\" content=\"Articles for Developers\" \/>\n<meta property=\"article:published_time\" content=\"2013-06-16T09:20:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-18T06:56:07+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ramandv\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ramandv.com\/blog\/#website\",\"url\":\"http:\/\/www.ramandv.com\/blog\/\",\"name\":\"Articles for Developers\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ramandv.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#webpage\",\"url\":\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/\",\"name\":\"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs - Articles for Developers\",\"isPartOf\":{\"@id\":\"http:\/\/www.ramandv.com\/blog\/#website\"},\"datePublished\":\"2013-06-16T09:20:54+00:00\",\"dateModified\":\"2014-06-18T06:56:07+00:00\",\"author\":{\"@id\":\"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658\"},\"description\":\"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs\"}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658\",\"name\":\"ramandv\",\"url\":\"http:\/\/www.ramandv.com\/blog\/author\/ramandv\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"description":"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/","og_locale":"en_US","og_type":"article","og_title":"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs  - Articles for Developers","og_description":"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.","og_url":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/","og_site_name":"Articles for Developers","article_published_time":"2013-06-16T09:20:54+00:00","article_modified_time":"2014-06-18T06:56:07+00:00","twitter_misc":{"Written by":"ramandv","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/www.ramandv.com\/blog\/#website","url":"http:\/\/www.ramandv.com\/blog\/","name":"Articles for Developers","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ramandv.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#webpage","url":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/","name":"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs - Articles for Developers","isPartOf":{"@id":"http:\/\/www.ramandv.com\/blog\/#website"},"datePublished":"2013-06-16T09:20:54+00:00","dateModified":"2014-06-18T06:56:07+00:00","author":{"@id":"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658"},"description":"This iterm2 applescript helps to launch the multiple tabs in iterm2 . And also you can name the tab. You can launch the tab with some start commands too.","breadcrumb":{"@id":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ramandv.com\/blog\/iterm2-applescript-opening-iterm2-with-multiple-tabs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Iterm2 AppleScript: Opening Iterm2 with multiple named tabs"}]},{"@type":"Person","@id":"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658","name":"ramandv","url":"http:\/\/www.ramandv.com\/blog\/author\/ramandv\/"}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6YZCe-1y","_links":{"self":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/96"}],"collection":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":24,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":293,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions\/293"}],"wp:attachment":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}