将 Warp 终端与 Alfred 集成

最近发现了一个很有趣的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

  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值