Jump to content

sirris

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by sirris

  1. 6 hours ago, deanishe said:

     

    As a rule, the solution Vítor suggested (altering PATH) is a much better one. Adjusting the local environment to a script is preferable to hardcoding a script to a specific environment.

     

    Thanks, makes sense. Any advice on how to do so? I can't seem to add a PATH statement to my .mjs script (it's in JavaScript). I'm attempting to following this instruction: Method 3: Set PATH before calling your tools. 

     

    I attempted putting it before the #! line-- it didn't work. Nor did creating a bash shell script (with the PATH statement) to run prior to my .mjs script.

  2. Thanks much @vitor! Using External Script.

     

    Here's what I get with two attempts:

     

    #!/usr/bin/env zx
    console.log('Testing 123');

     

    Gives error:

     

    [19:30:10.675] Logging Started...
    [19:30:12.617] ScrScriptipt[Hotkey] Processing complete
    [19:30:12.619] Script[Hotkey] Passing output '' to Run Script
    [19:30:12.632] ERROR: Script[Run Script] env: zx: No such file or directory
    [19:30:12.633] Script[Run Script] Processing complete
    [19:30:12.633] Script[Run Script] Passing output '' to Post Notification

     

    ...

    #!/opt/homebrew/bin/zx
    console.log('Testing 123');

     

    Gives nothing:

    [19:33:06.696] Script[Hotkey] Processing complete
    [19:33:06.701] Script[Hotkey] Passing output '' to Run Script

     

    Both paths resolve at shell to zx. And I can run the script in terminal with: "./script.mjs". I use zsh as my default shell.

  3. Google released an excellent new shell-scripting tool called zx that allows you to write shell scripts in JavaScript/JS with a bunch of helpful modules: https://github.com/google/zx -- i.e. things like Fetch built in.

     

    I've been unsuccessful at getting a zx script (.mjs) to work as an external script in an Alfred workflow. I've chmod +x, ensured paths are correct, and it still won't execute.

     

    I've even tried using a bash script to initiate the zx script:

     

    #!/bin/sh

    /opt/homebrew/bin/zx /Users/username/myscript.mjs

     

    Any advice? I'd love to be able to use this versatile new tool with Alfred!

×
×
  • Create New...