Craig Gardner
Craig Gardner

Reputation: 413

Arrow keys stop working when using less in a gnu screen session

Sometimes when I am using less within a screen tab, the arrow keys display ^[OA, ^[OB, ^[OC, and ^[OD instead of doing what I want them to do. Is there something I can do to fix this and gain control of less again?

Upvotes: 10

Views: 4685

Answers (4)

cdhowie
cdhowie

Reputation: 168948

I have found that reset from within screen does not solve the problem sometimes, as it's the outer client/shell whose state is actually confused and screen captures the control characters from reset and prevents them from reaching the outer client. In this situation, I have to detach my session (Ctrl+a, d), run reset, then attach to the session again (screen -r).

Upvotes: 5

borrel
borrel

Reputation: 922

enter !reset at the less prompt

Upvotes: 10

Lester Cheung
Lester Cheung

Reputation: 2030

Another thing to check is your TERM variable. In my case I ssh into a Linux box and run less inside screen - the TERM variable was set to 'screen' - which breaks arrow keys. It works perfectly if I run less this way:

TERM=xterm less <file>

Upvotes: 2

dma_k
dma_k

Reputation: 10639

  • If it happens from time to time, it seems, that some application (e.g. cat or less a binary file) shatters your console by sending it control characters. You need to run reset command from command line to recover.
  • Otherwise you have to trick your terminal application. I suggest you to use CryptoTerm which allows you to define custom key mappings.

Upvotes: 2

Related Questions