18

So there are I believe 2 questions on this already. All of them to do with tail -f and hence people give the tangent answer of "use less".

I need it for everything, every command, etc. The problem is I need to run a lot of console windows and even with multiple monitors still need to shrink them down. As a consequence just about every output is butchered by line wrapping and awkward to read.

One suggested solution is echo -ne '\e[?7l', which works, somewhat. The problem now, is there any way to get scroll bars on a console?

Ubuntu 12.10, Terminal

srcspider
  • 283
  • As an example (in response to all the "this isn't how terminals work" comments!) I'd point out the Ubuntu Console for Windows does support this feature. Applications such as ls and mcedit work fine in it, because screen width and buffer width are handled separately. – c z Mar 18 '20 at 14:57
  • I'm curious what the echo -ne '\e[?7l' actually does. I can see that it makes lines no longer wrap to the next line when you keep sending input, but... this just eats up the characters (sometimes for me it wraps around and other times it stays put on the last column). By scrollbar you are asking about how to navigate to view the rest of the content right? I think echo -ne '\e[?7l' will just have the terminal "eat" that content, it seems like it's lost. The purpose of this comment is just to point out that echo -ne '\e[?7l' isn't much of a solution because of this issue. – Steven Lu Apr 19 '21 at 19:51
  • OK. After searching a 2nd time, I found it in the xterm control sequences documentation:

    P s = 7 → No Wraparound Mode (DECAWM)

    – Steven Lu Apr 19 '21 at 20:04

2 Answers2

11

What you're asking is a terminal of infinite width, a portion of which is being displayed. It's not how terminals traditionally work nor how applications expect them to work.

For instance, if the terminal has infinite width, how are visual applications meant to work when they want to display something in the middle of the screen?

Something approaching that you can do though is use GNU screen (you're supposed to be able to attach a screen session from several terminals of different sizes so screen knows how to display a small window of a larger terminal) and set the screen windows width to something very large and then trick visual applications into thinking that the screen width is the original one.

Like (within screen)

c=$COLUMNS # assuming your shell has that variable
screen -X width -w 1000
stty cols "$c"

Some visual applications will work fine, some not so well (for install when they do relative positioning or when they rely on the terminal wrapping). vim seems to work OK.

Then to scroll and copy paste data, the only option is to use screen's copy mode. (<prefix>]) and move around the cursor (see info -f screen -n Movement for moving around in copy mode).

tmux may have similar capabilities.

This terminator terminal emulator (java based), which is not the terminator that comes with ubuntu also does just that with an infinite terminal width:

  • lines are never wrapped
  • visual applications are told the screen width is whatever fits in the window, not infinity.
  • it would also work better than the screen based solution above in that its terminfo entry claims it doesn't do line wrap so applications are aware of that, and BS at the start of the line doesn't move to end of the previous line.
  • 1
    I'm already in a gui environment so if I want to open a file in a visual editor I can just launch a gui one from the terminal. It's easier to copy in them then it is in a terminal anyway, since you can't really easily just drag select a block in a terminal with out it getting cutoff. Running screen -X width -w 1000 returns No screen session found., any ideas? – srcspider Mar 28 '13 at 13:28
  • @srcspider As I said, you need to do that within screen. Start screen first. – Stéphane Chazelas Mar 28 '13 at 13:46
  • okey I think I get you now, basically I should run screen -X width -w 1000 <mycommand> – srcspider Mar 28 '13 at 14:08
  • 2
    @srcspider. No. screen is a terminal based terminal emulator. So you need to start it first like you'd need to start xterm or gnome-terminal first, by running the screen command. Then, inside that new terminal emulator, you run that screen -X command to tell screen to change its window width. See also my edited answer for the terminator emulator which I suspect you'll prefer. – Stéphane Chazelas Mar 28 '13 at 14:25
  • Thanks! Even if somehow I don't get them to work, at least now I know why I can't get them to work like that. – srcspider Mar 28 '13 at 15:40
  • @srcspider, why can't you get terminator to work? – Stéphane Chazelas Mar 28 '13 at 15:43
  • Didn't say I couldn't get it to work. :) – srcspider Mar 29 '13 at 08:15
  • tmux may have similar capabilities ... But how do I use them??? – user3.1415927 Mar 22 '19 at 01:53
  • screen -X width -w 1000 worked for me, but how to scroll horizontally? can anyone help me! – Mohan Dec 30 '19 at 10:35
  • @MohanMunisifreddy, you can scroll in copy mode by moving the cursor around. – Stéphane Chazelas Dec 30 '19 at 17:25
  • @StéphaneChazelas , thanks. – Mohan Dec 30 '19 at 17:55
  • ... or just adjustable column width so that it can hold like 256 chars; normal log lines are not longer than that; if I have a 43'' long screen I think that's not infinite at last. Just a little bit wider than it is now; no wrapping but show things on a reasonable length line. – WesternGun Jul 07 '22 at 06:38
10

While Emacs is primarily an editor and IDE¹, it happens to match your problem very well. You can run a program inside an Emacs window, and Emacs displays it in a dumb terminal of infinite width and height. If the cursor is at the end of the buffer, the window will scroll as the program produces output; if you move the cursor around, the window will stay put as the output grows.

Type M-x shell RET (i.e. Alt+x shell Return) to start a shell in an Emacs buffer. Type C-u M-x shell RET or M-1 M-x shell RET to start another shell. You can run a program in each shell and arrange the buffers in multiple windows as you wish.

¹ It is sometimes said to be a better OS than editor, but only by people who don't use it — that's just a joke.