900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Mac finder中打开当前路径的Iterm2终端 超实用小工具

Mac finder中打开当前路径的Iterm2终端 超实用小工具

时间:2021-01-09 08:08:33

相关推荐

Mac finder中打开当前路径的Iterm2终端 超实用小工具

不知道读者们有没有遇到这样的场景,在mac finder的某个文件夹下面,想直接跳转到iterm2,跳过去的目录就是当前目录。从iterm2打开当前目录的finder很简单,直接"open ."即可,但是反过来就不是那么容易了,本文就是为了解决这个痛点。

先看下效果图:

如图所示进入一个文件夹,然后点击finder工具栏上的图标, 即可跳转到iterm2,pwd看一下目录就是跳转过来的目录。

下面讲解下具体步骤

1, 首先关注本公众号,并回复 finder2iterm,即可获得该脚本。

2, 然后mac上下载安装iterm2,可在官网直接下载,注意下载最新版本。

3, 然后在mac上打开app "脚本编辑器",点击左下角的 "新建文稿" 将下载到的脚本粘贴进去。

效果如下图所示:

(* Open Terminal Here A toolbar script for Mac OS X 10.3/10.4Written by Brian Schlining*)property debug : false-- when the toolbar script icon is clicked -- on runtell application "Finder"tryset this_folder to (the target of the front window) as aliason errorset this_folder to startup diskend trymy process_item(this_folder)end tellend run-- This handler processes folders dropped onto the toolbar script icon -- on open these_itemsrepeat with i from 1 to the count of these_itemsset this_item to item i of these_itemsmy process_item(this_item)end repeatend open-- this subroutine processes does the actual work -- this version can handle this weirdo case: a folder named "te'st"ö te%s`t"on process_item(this_item)set thePath to quoted form of POSIX path of this_itemset theCmd to "cd " & thePath & ";clear;"tell application "iTerm"activate-- just open a terminal and cd to thePath--set newWindow to (create window with default profile)set aWindow to current windowif aWindow is equal to missing value thenset aWindow to (create window with default profile)elsetell aWindowset t to (create tab with default profile)end tellend iftell current session of aWindowwrite text "cd " & thePath & ";clear;"end tellend tellend process_item

4, 点击 "文件 | 导出 … ",文件格式选择 "应用程序",导出为:自己取一个名字,此处取得finder2iterm, 位置选择要保存到的位置,然后点击"存储"。

然后同时按住"alt+cmd"将该应用程序拖拽到 finder的toolbar中。

大功告成!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。