blanu
V2EX  ›  Alfred

有没有能实时显示结果的 Node.js 运行时环境( REPL)的 Workflow

  •  
  •   blanu · Mar 2, 2017 · 3947 views
    This topic created in 3382 days ago, the information mentioned may be changed or developed.
    就是输入关键词+命令按回车直接就能显示结果。
    只找到一个能打开 node 命令的……然而这样的话要 alfred 何用呢……
    自己不太了解怎么写 Alfred 的 Workflow ,我猜想实现起来不难,不过先问问大家有没有用过(逃
    4 replies    2017-03-03 13:57:00 +08:00
    SoloCompany
        1
    SoloCompany  
       Mar 3, 2017
    应该很简单吧,直接用 shell workflow 执行 node -r <输入的剩余内容> 把结果回显到菜单区域,麻烦的是如果要考虑多行显示的话怎么优化的问题
    SoloCompany
        2
    SoloCompany  
       Mar 3, 2017
    说错,是 node -p 不是 -r
    minamike
        3
    minamike  
       Mar 3, 2017 via iPhone   ❤️ 1
    shell script for 循环 echo 结果每行到 xml 的 title 标签中
    不过结果的每一行中不能有空格 否则会断开
    minamike
        4
    minamike  
       Mar 3, 2017   ❤️ 1
    创建一个 script filter
    shell script
    ```
    result=$(/usr/local/bin/node -p {query}|pbcopy|pbpaste|sed 's#&#&amp;#g'|sed 's#<#&lt;#g'|sed 's#>#&gt;#g'|sed 's/ /_-_/g')
    list="$result"
    set -- $list
    xml=$(
    echo "<?xml version='1.0'?><items>";
    for i in $list; do
    echo "<item uid='result'><title>$i</title><subtitle></subtitle><icon>icon.png</icon></item>";
    done;
    echo "</items>")
    original="$(echo $xml | sed s'/_-_/ /g')"
    echo $original
    ```

    预览
    https://transfer.sh/UTYG7/screen-shot-2017-03-03-at-13.52.33.png

    https://transfer.sh/e3jb5/screen-shot-2017-03-03-at-13.52.22.png
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2714 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 15:25 · PVG 23:25 · LAX 08:25 · JFK 11:25
    ♥ Do have faith in what you're doing.