{"id":2495,"date":"2013-06-12T15:34:39","date_gmt":"2013-06-12T15:34:39","guid":{"rendered":"http:\/\/www.bartbusschots.ie\/blog\/?p=2495"},"modified":"2013-06-12T15:34:39","modified_gmt":"2013-06-12T15:34:39","slug":"os-x-service-terminal-here","status":"publish","type":"post","link":"https:\/\/www.bartbusschots.ie\/s\/2013\/06\/12\/os-x-service-terminal-here\/","title":{"rendered":"OS X Service &#8211; Terminal Here"},"content":{"rendered":"<p>I regularly find myself navigating to a folder in the Finder and then wanting to quickly get a Terminal window in the same location. In the past I would open a Terminal window, type <code>cd<\/code> and a space, then drag and drop the folder in question from the Finder into the Terminal and hit enter. Thanks to OS X&#8217;s great drag-and-drop support that works, and while it is easier than typing out the whole path (even with tab-complete), it&#8217;s still quite cumbersome.<\/p>\n<p>Today inspiration hit me &#8211; the <code>open<\/code> command should let me open a folder with the Terminal, so I tested it, and it does. Armed with this simple command line solution I opened up Automator and threw together a simple OS X service that takes a folder as input. The service has only one action, a <code>Run Shell Script<\/code> action with the shell set to <code>bash<\/code>, the input passed as arguments, and the following content:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nfor f in &quot;$@&quot;\r\ndo\r\n\t\/usr\/bin\/open &quot;$f&quot; -a \/Applications\/Utilities\/Terminal.app\/\r\ndone\r\n<\/pre>\n<p style=\"text-align:center;\"><a href=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.13.34.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.13.34-300x218.png\" alt=\"Screenshot of Service\" width=\"300\" height=\"218\" class=\"alignnone size-medium wp-image-2496\" style=\"border: 0px;\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.13.34-300x218.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.13.34.png 676w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>Click to Enlarge<\/a><\/p>\n<p>It will only take seconds to re-create this service yourself, but for convenience, I&#8217;ve zipped up my copy of the service and am attaching it to this post. Install it by unzipping and adding to either <code>~\/Library\/Services\/<\/code> (for just yourself) or <code>\/Library\/Services\/<\/code> (for all users).<\/p>\n<p style=\"text-align:center;\"><a href=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Terminal-Here.zip\"><img decoding=\"async\" alt=\"Download\" src=\"\/downloads\/download.png\" style=\"border:0px solid black\" \/><\/a><\/p>\n<p>Once the service is installed it will show up in the Services menu in the Finder when ever you have one or more folders selected:<\/p>\n<p style=\"text-align:center;\"><a href=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.23.06.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.23.06-300x245.png\" alt=\"Terminal Here Service In Action\" width=\"300\" height=\"245\" class=\"alignnone size-medium wp-image-2500\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.23.06-300x245.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.23.06.png 887w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>Click to Enlarge<\/a><\/p>\n<p>You can also get to the service by right-clicking on any folder in the Finder:<\/p>\n<p style=\"text-align:center;\"><a href=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.36.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.36-300x287.png\" alt=\"Terminal Here Service In Action - Right Click\" width=\"300\" height=\"287\" class=\"alignnone size-medium wp-image-2502\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.36-300x287.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.36.png 792w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>Click to Enlarge<\/a><\/p>\n<p>Finally &#8211; if you keep the optional Path Bar shown in the Finder you can also right-click on a Folder there to access the service (including the folder you are in):<\/p>\n<p style=\"text-align:center;\"><a href=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.58.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bartbusschots.ie\/blog\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.58-300x194.png\" alt=\"Terminal Here Service in Action - Path Bar\" width=\"300\" height=\"194\" class=\"alignnone size-medium wp-image-2503\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.58-300x194.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-12-at-16.29.58.png 993w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>Click to Enlarge<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I regularly find myself navigating to a folder in the Finder and then wanting to quickly get a Terminal window in the same location. In the past I would open a Terminal window, type cd and a space, then drag and drop the folder in question from the Finder into the Terminal and hit enter. [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"series":[],"class_list":["post-2495","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7t9xK-Ef","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/comments?post=2495"}],"version-history":[{"count":6,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2495\/revisions"}],"predecessor-version":[{"id":2506,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2495\/revisions\/2506"}],"wp:attachment":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/media?parent=2495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/categories?post=2495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/tags?post=2495"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/series?post=2495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}