Pipe to less -S without clearing output from command line history

so I want to use horizontal scrolling in the terminal for my custom bash command by connecting the output of the command to | less -S

However, if I do this, as soon as you exit less, the output of the command will not remain in the command line history

Is there a way to configure less to keep the output of the command in history when exiting less?

Eg. if you look at git diff, you can scroll horizontally and then exit, but the output will remain in the history in which you can enter new commands ... I essentially want to emulate this for my custom bash command. Also in git diffit performs horizontal scrolling in place (i.e., without using a new screen), and the command line history is still visible, while for lessit it will do it on its own screen, and you will not be able to see the command line history with " decrease ". Could this git diff-like mechanism be emulated less?

If there is another solution without use less, feel free to throw it away.

UPDATE QUESTION

So, suppose I do this:

cat loremipsum | less -FRSX

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sed 

, . q, . , , :

cat loremipsum | less -FRSX

 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sed 

 ESCOC

dictum diam. Nullam quis urna ullamcorper, accumsan quam vitae, aliquet 

 ESCOD

nisl. Maecenas vitae lorem orci. Ut vel est erat. Cras quis sagittis sapien, ac volutpat metus. 

 username@server:~/httpdocs$

git diff, , q, (.. , )

 git diff

nisl. Maecenas vitae lorem orci. Ut vel est erat. Cras quis sagittis sapien, ac volutpat metus. 

 username@server:~/httpdocs$

?

+4
3

, git diff , , , -X . .

ls -la | less -SX

, .

git , git diff:

$ pstree -p | grep git
        |-xterm(6021)---bash(6023)---sh(6104)---git(17708)---less(17709)
$ cat /proc/17709/cmdline | xargs -0 echo
less
$ cat /proc/17709/environ | xargs -0 --replace echo {} | grep LESS
LESSOPEN=|/usr/bin/lesspipe.sh %s
LESS=FRSX
$ 

git diff less. less FRSX. , -FRSX . , , , -FRSX:

ls -la | less -FRSX
+9

, .

, ncurses, escape-, . , . . , - .

less ( vim - ) , , . , xterm, - :

command > command.log ; xterm -e less -S command.log

script. GUI, screen - .

, , less ( ), terminfo, , t . terminfo tmcup rmcup. , , ; , titeInhibit xterm.

( , .)

:

DigitalTrauma , -X ( --no-init) less termfix/terminfo (ti/te termcap, smcup/rmcup terminfo). -X less, X $LESS, .

, less. , , - . titeInhibit xterm termcap terminfo, escape-, .

+2

:

export LESS=X # it might be what you are looking for
0

All Articles