Termux-app: cut and paste on chromebook

Created on 25 Jul 2017  Â·  6Comments  Â·  Source: termux/termux-app

I have termux running on a chromebook. It works great, but I can't figure out how to cut and paste text between it and the chromebook apps (such as the browser). Is it possible?

Most helpful comment

if you use tmux, you can set it up to use a shell script to copy data to/from your buffers.

like so:

~/Bin » cat pbcopy
termux-clipboard-set $1
~/Bin » cat pbpaste
termux-clipboard-get
~/Bin » cat ~/.tmux.conf|grep pb
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"

You can also do something like this:

bind C-y run "tmux show-buffer | pbcopy"
bind C-p run "pbpaste | tmux load-buffer - && tmux paste-buffer"

But the copy-mode line above should work fine, and you can use ctrl+alt+v to paste.

Anyway, even with just those pbcopy and pbpaste scripts (modeled after the same commands on OSX) you can just echo things into the clipboard, but integrating it with tmux so you can grab text off the screen works pretty well.

The alternative is to use SSH via the "secure shell" app and then you can copy by selecting text, and paste by "middle mouse" or 3-finger-tap. Also, selecting text, and pasting with 3 finger tap also works on termux directly too.

All 6 comments

@jots,

From the 'User interface' page, use a long press -

The context menu can be shown by long pressing anywhere on the terminal. It provides menu entries for:

Selecting and pasting text.
Sharing text from the terminal to other apps (e.g. email or SMS)
Resetting the terminal if it gets stuck.
Switching the terminal to full-screen.
Hangup (exiting the current terminal session).
Styling the terminal by selecting a font and a color scheme.
Showing this help page.

I'm using a Chromebook too and had to look it up just recently :)

Hope this helps,
-DennisL

I can long press and highlight text but, I can't seem to figure out how to copy it. CTRL+C doesn't work, long pressing again after highlighting doesn't seem to do anything. I'm specifically on a chromebook (Samsung Chromebook Pro) and trying this both with the touch screen (doesn't register any presses in Termux) and using the touche pad (registers the long press).

I would merely like to be able to copy and paste from a Termux screen into a webpage.

if you use tmux, you can set it up to use a shell script to copy data to/from your buffers.

like so:

~/Bin » cat pbcopy
termux-clipboard-set $1
~/Bin » cat pbpaste
termux-clipboard-get
~/Bin » cat ~/.tmux.conf|grep pb
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"

You can also do something like this:

bind C-y run "tmux show-buffer | pbcopy"
bind C-p run "pbpaste | tmux load-buffer - && tmux paste-buffer"

But the copy-mode line above should work fine, and you can use ctrl+alt+v to paste.

Anyway, even with just those pbcopy and pbpaste scripts (modeled after the same commands on OSX) you can just echo things into the clipboard, but integrating it with tmux so you can grab text off the screen works pretty well.

The alternative is to use SSH via the "secure shell" app and then you can copy by selecting text, and paste by "middle mouse" or 3-finger-tap. Also, selecting text, and pasting with 3 finger tap also works on termux directly too.

Note that for the above scripts to be sourced properly without extra work, place them in $PREFIX/bin.

cp pbcopy pbpaste $PREFIX/bin
chmod +x $PREFIX/bin/pbcopy
chmod +x $PREFIX/bin/pbpaste

I placed this logic in my tmux.conf:

cat ~/.tmux.conf | grep -A 4 pbcopy
# This assumes you have copied pbcopy/pbpaste into $PREFIX/bin from the github bin/ dir
# clipboard
if-shell "if [[ "$(uname -o)" = "Android" ]]; then \
    bind-key C-y copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"; \
  else  \
    bind-key -t vi-copy 'v' begin-selection; \
    bind-key -t vi-copy 'y' copy-selection; \
  fi"

termux-api must be installed in order to have termux-clipboard-* commands

From the Termux help, the Hardware Keyboard entry states:

The following shortcuts are available when using Termux with a hardware (e.g. bluetooth) keyboard by combining them with Ctrl+Alt:

‘C’ → Create new session
‘R’ → Rename current session
Down arrow (or ‘N’) → Next session
Up arrow (or ‘P’) → Previous session
Right arrow → Open drawer
Left arrow → Close drawer
‘M’ → Show menu
‘U’ → Select URL
‘V’ → Paste
+/- → Adjust text size
1-9 → Go to numbered session

So CTRL-ALT-V pastes (which I've confirmed), but oddly nothing for copy.

Was this page helpful?
0 / 5 - 0 ratings