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 working with the Raspbian Linux distro that comes with the Raspberry Pi.

I am running the Pi so that I can only operate it from the command line, so I have no user interface and therefore no mouse. My problem is that I wanted to copy a few lines of code off of the command line but I realized that if I try to move the cursor up using the arrow keys on my keyboard it will instead print previous commands, so I was wondering if there is a way to move around and select a few lines code and copy to later paste?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You will need to install GNU screen if it isn't already installed. When you log in, start up screen.

To copy-and-paste,

1) Press Ctrl+A, followed by ESC
2) Use the arrow keys and navigate to where you want to start selecting text, and...
4) Press Space to set the beginning mark
5) Use arrow keys to select the text
6) Press Space again to 'finish' the select
7) Now reactivate "Normal" screen mode by typing Ctrl+A
8) Now paste by typing ]

This is (believe it or not) the simplest way to copy-and-paste output to input that I know of.

P.S. GNU Screen comes with lots of other nifty tricks, such as detaching (handy when using SSH), and much more!

share|improve this answer
    
I would also give a hearty recommendation to tmux. I'm not too familiar with the differences, but I've used both and personally prefer tmux. I'd recommend trying both and see what suits you. (Since once you start using a screen multiplexer, you'll probably never go back) –  MetaNova Jan 11 at 17:25
    
@MetaNova Oh yes, I had forgotten tmux. When I was in the search for a terminal multiplexer I heard of both, but I tried GNU screen first and it suited my needs, so I used it. I should probably look into tmux. –  BenjiWiebe Jan 11 at 18:22
    
I think you'll find that tmux has a lot of extra niceties. ;) –  MetaNova Jan 11 at 23:05
    
This works, Thanks a lot for the help! –  fespinov Jan 15 at 16:26
    
@user3185216 To accept the answer, click the checkmark beside the answer. –  BenjiWiebe Jan 15 at 19:43

I realize this may not be exactly what you asked, but if you have network connection to the Pi, you could ssh to the box from your PC and use the copy-paste feature of your terminal program.

Screen and tmux are convenient tools also in this case, if you like to be able to run programs continuously from the terminal in the Pi and don't want to worry about accidentally killing the programs if the terminal connection fails.

share|improve this answer

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.