iterm2的安装

官方地址: https://iterm2.com/

脚本编辑器

img.png
新建一个文件,粘贴下面的脚本内容
img.png

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(* 


Open Terminal Here

A toolbar script for Mac OS X 10.3/10.4

Written by Brian Schlining
*)


property debug : false


-- when the toolbar script icon is clicked
--
on run
tell application "Finder"
try
set this_folder to (the target of the front window) as alias
on error
set this_folder to startup disk
end try

my process_item(this_folder)

end tell
end run




-- This handler processes folders dropped onto the toolbar script icon
--
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
my process_item(this_item)
end repeat
end 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_item
set 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 window

if aWindow is equal to missing value then
set aWindow to (create window with default profile)
else
tell aWindow
set t to (create tab with default profile)
end tell
end if


tell current session of aWindow
write text "cd " & thePath & ";clear;"
end tell

end tell


end process_item


保存为应用程序

img.png

打开刚才保存的路径,按住control+command 拖动到finder到固定位置即可

img.png

当需要打开终端的时候,只需要在finder对应的文件夹中点击 刚才的图标即可!

img.png

即可打开iterm,并进入对应的目录

img.png