Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am looking for a way to copy and paste within a TTY. I only have a touchpad, and using it with gpm is a pain. The only possibility I can think of is to use "screen" but even after having remapped Ctrl-A to "`", it is still inconvenient and slow.
Are there any more-comfortable approaches?

share|improve this question
1  
Interesting question. GPM has been around for a long time and I haven't heard a lot of complaints, so I'm a little dubious about finding a good alternative... –  dmckee Nov 8 '09 at 21:31
    
gpm works fine here but it is not flexible enough for my needs. Navigating using the keyboard is much faster than using the mouse. Therefore I also prefer VIM instead of graphical editors. So VIM-inspired key bindings for TTYs could enhance navigation. –  timn Nov 8 '09 at 21:53
    
IMHO after testing it I would recommend using screen for copy-paste. It supports all console apps, so You can copy and paste with lynx/links. –  naugtur Jun 18 '10 at 10:44
add comment

5 Answers 5

If you don't like screen or gpm, your alternatives are quite limited. The other options I can think of are:

  1. Run terminals under X, maybe using a tiling window manager for a minimalist, console-like look.

  2. Run a *BSD instead of Linux, which will let you use sysmouse instead of gpm. I hear it's better, and my limited BSD experiences suggest that it may very well be better, but I don't know if it's better in the area of clipboard support. Sounds like you mostly just don't like your trackpad though, which is probably unfixable without replacement.

  3. Use pipes, named pipes, scratchfiles, etc. For example, most unix editors will let you process selected text via normal command line scripts, which could be setup to save the selection to ~/.clipboard, for instance. Running commands that input text (cat ~/.clipboard) should be even easier.

  4. Use an editor that supports multiple files, and copying/pasting across them. vim does, and emacs does too, I'm sure.

share|improve this answer
    
+1 for FreeBSD! –  kolypto Nov 9 '09 at 3:59
    
1) There are a few flaws with the X-Server that prevent me from being effective in it. The first one is that the keyboard strangely reacts much slower than in the framebuffer. This really annoys me as scrolling in a document (VIM) in a URxvt is not by far as fast as a VIM started in a TTY. The next issue is the performance. Although I am using KMS and a tiled window manager (i3), the X-Server does not start up immediately. Neither do the applications. Even small applications such as URxvt take various seconds to start. –  timn Nov 9 '09 at 18:12
    
What also troubles me is the bloat. X.org is a huge chunk of complex code. As I am not a gamer, nor do I have to maintain many remote desktops, personally I have absolutely no need for direct rendering, X forwarding etc. Actually, the framebuffer offers all I need for working. Only the number of available applications is a bit limited. :) 2) This would not really solve my problem as I want to get rid of my mouse. –  timn Nov 9 '09 at 18:16
    
3) Yes, that is what I am currently doing whenever I want to visit a link within a plain text document in VIM but honestly, copying the link into the buffer with "yy", then typing ":tabnew url" followed by a "p" for pasting and a final "w3m $((cat url))" on the shell is not as comfortable as an URxvt with "clickable" links. –  timn Nov 9 '09 at 18:17
add comment

You can use ctrl+y to paste. To copy, it depends of what you want to copy. If it is on the prompt : ctrl+u to cut from the begining, ctrl+k to cut until the end.

share|improve this answer
    
Thanks. These key bindings are really useful. Unfortunately I can only make use of them when I am working on the shell but not in text-browsers or other console tools. –  timn Nov 9 '09 at 17:34
add comment

depending on what you are trying to copy and paste... bash does have a vi mode which you can edit your commands in a more like vi way than emacs(bash default) (zsh has a vim mode). putting set -o vi in ~/.bashrc enable's it.

share|improve this answer
    
Nice! As I am also VIM user, key bindings similar to the VIM ones come in handy. Actually, one small problem persists: Sometimes there are websites where URLs are not hyperlinked but rather in plain text. If I visit such websites in w3m, I would have to manually copy that link in order to navigate to it. Another example is VIM: If I am viewing a document containing URLs, it is not possible to just "click" them (as in URxvt). Here as well, I have to manually copy them. These are the only two applications, a global clipboard support could be useful. Any ideas? –  timn Nov 9 '09 at 17:48
add comment

tmux is similar to screen and gives you the ability to copy-paste.

dvtm can copy/paste with mouse.

share|improve this answer
add comment

Try this:

ls $(xsel -o --display :0)

If there is "wa*" in the clipboard it will produce this in any TTY terminal:

$ ls -l  $(xsel -o --display :0)
-rwxr-xr-x 1 root root 1254 Jan 30 11:44 wav_to_mp3.sh
$ 

Maybe it can be made even easier via bash aliases. Anyway I solved that finally this way:

1) copy text into clipboard in TTY7 - GUI 2) then I switch into say TTY1 and I write command: expandclipboard.sh youtube-dl cb 3) the script expands the command and inserts the content of the clipboard at the place of cb and runs is.

the code of the script is:

    #!/bin/bash
    var1=$1
    if [ "$var1" = "cb" ]; then
    var1=$(xsel -o --display :0)
    fi

    var2=$2
    if [ "$var2" = "cb" ]; then
    var2=$(xsel -o --display :0)
    fi

    var3=$3
    if [ "$var3" = "cb" ]; then
    var3=$(xsel -o --display :0)
    fi

    var4=$4
    if [ "$var4" = "cb" ]; then
    var4=$(xsel -o --display :0)
    fi

    var5=$5
    if [ "$var5" = "cb" ]; then
    var5=$(xsel -o --display :0)
    fi

    var6=$6
    if [ "$var6" = "cb" ]; then
    var6=$(xsel -o --display :0)
    fi

    var7=$7
    if [ "$var7" = "cb" ]; then
    var7=$(xsel -o --display :0)
    fi

    var8=$8
    if [ "$var8" = "cb" ]; then
    var8=$(xsel -o --display :0)
    fi

    echo $var1 $var2 $var3 $var4 $var5 $var6 $var7 $var8
    $var1 $var2 $var3 $var4 $var5 $var6 $var7 $var8

I know it is immensely primitive, but I am lazy to pretend that I am any cleverer than this script. :-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.