raycast / script-commands

Script Commands let you tailor Raycast to your needs. Think of them as little productivity boosts throughout your day.

Home Page:https://raycast.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the new version of Raycast script cannot send text to clipboard?

baker221 opened this issue · comments

I write a Python script of OCR.
The beginning part of script:

#!/usr/bin/env python3

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title ocr
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 

The clipboard operation part:

    import pyperclip
    pyperclip.copy(content)
    print("Success!")

In the old version, this works well. But now (version 1.51.3) after running it, the clipboard is still empty.

But when I run it in console, this works well.

The bash command of pbcopy or something cannot operate correctly now

This is weird, in this version of Raycast, if the content is Chinese, it cannot work. But if I use this script in terminal, both can work well.

    # pyperclip.copy("你好") # not work
    pyperclip.copy("hello") # work
    print("Success!")

I also test the following:

    import pyperclip
    pyperclip.copy(content)
    print(pyperclip.paste())

The output is empty if the content has Chinese.

But if I just print it:

    print("你好")

This can work and display.

I write a new simple script and I am confirmed that this is the problem of new version Raycast.

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title mytest
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 📋

# Documentation:
# @raycast.description hello

#echo "haha" | pbcopy # works
echo "你好" | pbcopy # do not work
echo "Clipboard emptied"

same problem for me

Hey @baker221 and @YHsilver,

Thank you for writing and sorry this took long to answer. I just tried your script and everything works as expected (see below).

Terminal

It looks like it has something to do with the terminal environment. Can you think of anyway I can replicate?

In my computer, this doesn't work, the result is as below:
Snipaste_2023-05-30_18-46-46
Now my Raycast version is 1.52.1. My macOS version is 12.6.5. I changed the first line into /bin/sh, but it cannot work either. I will try to find a way for you to reproduce it.

Hey @baker221 and @YHsilver,

Thank you for writing and sorry this took long to answer. I just tried your script and everything works as expected (see below).

Terminal It looks like it has something to do with the terminal environment. Can you think of anyway I can replicate?

I see that the "character" is 3. But "你好" just have 2 characters. If I copy "你好" directly, the character is 2. (But even if I added a space before this string, the script still cannot work)
Snipaste_2023-05-30_18-53-25

same problem

commented

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

Do you have any idea solving this issue until now? This version (1.54.1) still cannot work.

commented

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

Still no solution? @dehesa

Still no solution? @dehesa

I found that. The Raycast's locale somehow changed in a new version.

Change the pbcopy into below:

echo "你好" | LANG=zh_CN.UTF-8 pbcopy
commented

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.