胖五talk

Alfred使用手册(一)

Alfred作为Mac系统上效率类软件的第一神器,如果不经过好好调教实在是有点浪费了。

打开网页

直接在弹出框中输入关键字,然后跳转到对应的网站查询

上面的用法应该是最简单有效的查询方式了,想达到这点需要2个步骤

  • Web Search中添加你需要的自定义查询
  • Default Result中Setup fallback results添加自定义查询

Web Search中添加你需要的自定义查询

首先把你常用的网站的查询url拿到,比如百度的就是 https://www.baidu.com/s?wd=关键字 然后替换关键字为Alfred中的查询条件{query},keyword设置你觉得好记的即可,icon的话添加上可以让显示更加直观些

Setup fallback results添加自定义查询

一些常用网站的查询url

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 百度
https://www.baidu.com/s?wd={query}
// 百度百科
https://baike.baidu.com/search/word?enc=utf-8&word={query}
// 百度贴吧
https://tieba.baidu.com/f?kw={query}
// 知乎
https://www.zhihu.com/search?q={query}
// 淘宝
https://s.taobao.com/search?q={query}
// 京东
https://search.jd.com/Search?keyword={query}
// 少数派
https://sspai.com/search/article?q={query}

其他网站就自行分析下网站链接就好了

执行命令

为了使用Mac上最好用的终端appiTerm2来打开窗口执行命令,需要一段AppleScript来进行关联

Github上已经有人写好了,直接根据你的iTerm版本copy过来即可, 具体设置看下图

这里直接贴一下2.9+(包含3.0beta)

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
-- This is v0.6 of the custom script for AlfredApp for iTerm 2.9+
-- Please see https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/
-- for the latest changes.
-- Please note, if you store the iTerm binary in any other location than the Applications Folder
-- please ensure you update the two locations below (in the format of : rather than / for folder dividers)
-- this gets around issues with AppleScript not handling things well if you have two iTerm binaries on your system... which can happen :D
on alfred_script(q)
if application "iTerm2" is running or application "iTerm" is running then
run script "
on run {q}
tell application \":Applications:iTerm.app\"
activate
try
select first window
set onlywindow to false
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 \":Applications:iTerm.app\"
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