Termux-app: termux-clipboard is not so easy to install (in order to support copy paste via pbcopy, pbpaste commands)

Created on 1 Nov 2018  路  16Comments  路  Source: termux/termux-app

On macOS X, the pbcopy and pbpaste command can be used to manipulate the clipboard.

On Desktop linux that's the xclip -selection command, so I made alias pbcopy='xclip -selection clipboard' and alias pbpaste='xclip -selection clipboard -o' for the command to be portable with macOS X.

That's very useful for a lot of text replacement applications :

pbpaste > file.txt     # into a file
pbcopy file.txt        # from a file
cat file.txt | pbcopy  # from a file, using a pipe
pbpaste | sed 's/ /-/g' | pbcopy  # direct replacement of clipboard
pbpaste | python 'import sys
sys.stdout.write(sys.stdin.read().replace(" ", "-"))
' | pbcopy  # use python for more complicated Operations !
pbpaste | python replace_stuff.py | pbcopy  # why not from a python file ?

I have no clue how clipboard work in android but I think that's manageable !

Most helpful comment

It hangs for me too. I'm on Android 9

All 16 comments

Humm, so alias pbcopy=termux-clipboard-set, and alias pbpaste=termux-clipboard-get in theory, however I get this error :

~ termux-clipboard-get
cmd: Can't find service: activity

@robertvandeneynde Termux:API is installed ? Make sure that both app and package are installed.

I did pkg install termux-api, should I do more ? What do you mean by app and package ?

@robertvandeneynde app is this: https://play.google.com/store/apps/details?id=com.termux.api, package is pkg install termux-api.

See https://wiki.termux.com/wiki/Termux:API

Access to system clipboard is possible only through Android Clipboard API.

Alright ! I've downloaded the termux api app on the store, but I still get cmd: Can't find service: activity should I run it or something ?

@robertvandeneynde Termux api commands should just work. The error cmd: Can't find service: activity may point on bug of Termux or ROM...

termux-clipboard-get/set support should probably be moved into the main Termux app and not require Termux:API, since these are basic useful operations which does not require any additional permissions in the core app.

I installed termux-api and I'm having trouble using termux-clipboard-get command on a chromebook.

It just hangs for me.

It hangs for me too. I'm on Android 9

Works for me:

  • Android 8.1.0, Oreo, (LG Phoenix Plus)

hangs on Android 8.1 (xiaomi redmi 5 plus)

Hangs for me too.

termux-clipboard-set/get just work on my pie device, except it's almost always truncate the last char I copied #1011

Works for me:

  • Android 10, (Asus Zenfone 6)

Neither set nor get works on Android 9,

Was this page helpful?
0 / 5 - 0 ratings