最近发现了一个很有趣的MAC终端——Wrap,非常的酷帅,下载地址为Warp: Your terminal, reimagined。
然而使用Alfred打开的始终是电脑默认的终端,所以想要将其替换为Wrap,所以就有了本篇文章。
操作过程
1.打开Alfred Preference,选择Terminal,将Application从Terminal改为Custom
2.然后将下面的编辑框中的脚本内容替换为下面的内容
-- For the latest version:
-- https://gist.github.com/parterburn/e832b9090ee35eb830529de8bd978b82
-- Set this property to true to always open in a new window
property open_in_new_window : false
-- Set this property to false to reuse the current tab
property open_in_new_tab : true
-- Handlers
on new_window()
tell application "System Events"
tell process "Warp"
keystroke "n" using command down
end tell
end tell
end new_window
on new_tab()
tell application "System Events"
tell process "Warp"
keystroke "t" using command down
end tell
end tell
end new_tab
on call_forward()
tell application "Warp" to activate
end call_forward
on send_text(custom_text)
tell application "System Events"
tell process "Warp"
delay 0.5
keystroke custom_text
delay 0.5
key code 36
end tell
end tell
end send_text
-- Main
on alfred_script(query)
call_forward()
if open_in_new_window then
new_window()
else if open_in_new_tab then
new_tab()
else
-- Reuse the current tab
end if
call_forward()
send_text(query)
end alfred_script
对应的链接为https://gist.github.com/parterburn/e832b9090ee35eb830529de8bd978b82
如果想要简单点,不需要自定义选项卡和窗口等行为则可以简化为以下内容:
on alfred_script(q)
tell application "System Events"
tell application "Warp" to activate
set numWin to count (windows of process "Warp")
if numWin < 1 then keystroke "n" using command down
delay 0.5
keystroke q
keystroke return
end tell
end alfred_script