Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to copy a newline to clipboard using adb shell? #54

Open
rodrigomorales1 opened this issue Oct 8, 2023 · 1 comment
Open

How to copy a newline to clipboard using adb shell? #54

rodrigomorales1 opened this issue Oct 8, 2023 · 1 comment

Comments

@rodrigomorales1
Copy link

rodrigomorales1 commented Oct 8, 2023

Context

I know that I can use the following command to copy a string to the clipboard

$ adb shell am start-activity \
  -a android.intent.action.SEND \
  -e android.intent.extra.TEXT "foo" \
  -t text/plain \
  com.tengu.sharetoclipboard

I also know that when the string has a space character, the space character needs to be escaped

$ adb shell am start-activity \
  -a android.intent.action.SEND \
  -e android.intent.extra.TEXT "foo\ bar" \
  -t text/plain \
  com.tengu.sharetoclipboard

Now, I want the string to have a newline character. I've tried the following commands with no avail.

$ adb shell am start-activity -a android.intent.action.SEND -e android.intent.extra.TEXT "foo\nbar" -t text/plain com.tengu.sharetoclipboard
$ adb shell am start-activity -a android.intent.action.SEND -e android.intent.extra.TEXT "foo\\nbar" -t text/plain com.tengu.sharetoclipboard
$ adb shell am start-activity -a android.intent.action.SEND -e android.intent.extra.TEXT "foo\rbar" -t text/plain com.tengu.sharetoclipboard
$ adb shell am start-activity -a android.intent.action.SEND -e android.intent.extra.TEXT "foo\\rbar" -t text/plain com.tengu.sharetoclipboard

Any ideas on how to make the newline character to be inserted in the clipboard?

System information

  • Phone model name: Samsung Galaxy A12
  • Phone model number: SM-A127M
  • Android v11
  • Share to Clipboard v1.15.0

PS: I referenced this issue in this comment at Stack Overflow.

@HusniMuhammad
Copy link

For adb users

adb shell am start -a android.intent.action.SEND \
    --es android.intent.extra.TEXT "$(echo -e 'Hi\nHow')" \
    -t text/plain \
    com.tengu.sharetoclipboard

For termux

am start -a android.intent.action.SEND \
    --es android.intent.extra.TEXT "$(echo -e 'Hi\nHow')" \
    -t text/plain \
    com.tengu.sharetoclipboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants