Skip to content

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

Description

@rodrigo-morales-1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions