Alfred是Mac下一个非常强大的工具,网上有许多如何使用的教程,我目前也只是会使用一些基本功能。其中一个我特别喜欢的功能就是直接可以在Alfred里面输入shell命令(默认需要在命令前家>符号,表示是shell命令),然后就会自动打开终端执行。但这里有个问题就是Alfred默认使用Mac自带的Terminal,而大多数在Mac经常使用终端的一般都会使用iTerm2,因为它配合zsh+oh my zsh,真的是非常强大。对于目前最新的iTerm 3.x版本,可以通过如下方法将Alfred内置的Terminal改为iTerm2:
打开Alfred的"Preferences->features->Terminal/shell",将"Application"选为"custom",然后将下面的编辑框中的脚本内容替换为下面的内容:
-- This is v0.7 of the custom script for AlfredApp for iTerm 3.1.1+ -- created by Sinan Eldem www.sinaneldem.com.tr on <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/alfred" title="View all posts in alfred" target="_blank">alfred</a></span>_script(q) if application "iTerm2" is running or application "iTerm" is running then run script " on run {q} tell application \"iTerm\" activate try select first window set onlywindow to true on error create window with default profile select first window set onlywindow to true end try tell the first window if onlywindow is false then create tab with default profile end if tell current session to write text q end tell end tell end run " with parameters {q} else run script " on run {q} tell application \"iTerm\" activate try select first window on error create window with default profile select first window end try tell the first window tell current session to write text q end tell end tell end run " with parameters {q} end if end <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/alfred" title="View all posts in alfred" target="_blank">alfred</a></span>_script
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
|
--
This
is
v0
.
7
of
the
custom
script
for
AlfredApp
for
iTerm
3.1.1
+
--
created
by
Sinan
Eldem
www
.
sinaneldem
.
com
.
tr
on
alfred_script
(
q
)
if
application
"iTerm2"
is
running
or
application
"iTerm"
is
running
then
run
script
"
on run {q}
tell application \"iTerm\"
activate
try
select first window
set onlywindow to true
on error
create window with default profile
select first window
set onlywindow to true
end try
tell the first window
if onlywindow is false then
create tab with default profile
end if
tell current session to write text q
end tell
end tell
end run
"
with
parameters
{
q
}
else
run
script
"
on run {q}
tell application \"iTerm\"
activate
try
select first window
on error
create window with default profile
select first window
end try
tell the first window
tell current session to write text q
end tell
end tell
end run
"
with
parameters
{
q
}
end
if
end
alfred
_script
|