alfred自定义脚本执行报错,alfred task launch path not accessible
原因是mac升级后 /usr/lib/php 已经不存在了,可以改由zsh方式执行,如下图
右击打开目录
将执行脚本放入目录
code如下:
<?php
require './Util.php';
$qs = $argv;
$query = $qs[1];
date_default_timezone_set("Asia/Shanghai");
$u = new Util();
$ts = "/^\d{10}$/";
$ymd = "/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/";
$ymdhis = "/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/";
$show = [
'arg'=>time(),
'title'=>time(),
'subtitle'=>'[WARNING] Ymd|YmdHis|Timestamp Only(copy now)'
];
if(preg_match($ymd,$query) || preg_match($ymdhis,$query)){
$show = [
'arg'=>strtotime($query),
'title'=>strtotime($query),
'subtitle'=>'[SUCCESS] Ymd To Timestamp(copy now)'
];
}elseif (preg_match($ts,$query)){
$show = [
'arg'=>date("Y-m-d H:i:s",$query),
'title'=>date("Y-m-d H:i:s",$query),
'subtitle'=>'[SUCCESS] Timestamp To YmdHis(copy now)'
];
}
$u->result([$show]);
<?php
class Util
{
/**
* Descrition:输入结果
* @param $arr
* Created At: 2020/5/20 6:06 PM
* Author: eric
*/
public function result($arr){
echo json_encode([
'items'=>$arr
]);
exit();
}
}