Skip to main content
Rollback to Revision 6 - Edit approval overridden by post owner or moderator
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success. The best solution is as follows:-

  1. $ infocmp -I xterm > ~/xterm-noclear.src

  2. Edit ~/xterm-noclear.src

    • change the name on the second line from 'xterm' to 'xterm-noclear', or whatever suits you (also change 'xterm-debian' if it's present)
    • remove the instructions 'smcup' and 'rmcup' (e.g. "smcup=\E[?1049h, " and "rmcup=\E[?1049l, ")
  3. $ mkdir ~/.terminfo

  4. $ tic ~/xterm-noclear.src (x/xterm-noclear should appear in your ~/.terminfo directory)

  5. $ export TERM=xterm-noclear (now check the behaviour of less and, if satisfied, add the export directive line to your ~/.profile)

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success. The best solution is as follows:-

  1. $ infocmp -I xterm > ~/xterm-noclear.src

  2. Edit ~/xterm-noclear.src

    • change the name on the second line from 'xterm' to 'xterm-noclear', or whatever suits you (also change 'xterm-debian' if it's present)
    • remove the instructions 'smcup' and 'rmcup' (e.g. "smcup=\E[?1049h, " and "rmcup=\E[?1049l, ")
  3. $ mkdir ~/.terminfo

  4. $ tic ~/xterm-noclear.src (x/xterm-noclear should appear in your ~/.terminfo directory)

  5. $ export TERM=xterm-noclear (now check the behaviour of less and, if satisfied, add the export directive line to your ~/.profile)

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success.

Import a linked solution, lest the target disappear
Source Link

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success. The best solution is as follows:-

  1. $ infocmp -I xterm > ~/xterm-noclear.src

  2. Edit ~/xterm-noclear.src

    • change the name on the second line from 'xterm' to 'xterm-noclear', or whatever suits you (also change 'xterm-debian' if it's present)
    • remove the instructions 'smcup' and 'rmcup' (e.g. "smcup=\E[?1049h, " and "rmcup=\E[?1049l, ")
  3. $ mkdir ~/.terminfo

  4. $ tic ~/xterm-noclear.src (x/xterm-noclear should appear in your ~/.terminfo directory)

  5. $ export TERM=xterm-noclear (now check the behaviour of less and, if satisfied, add the export directive line to your ~/.profile)

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success.

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success. The best solution is as follows:-

  1. $ infocmp -I xterm > ~/xterm-noclear.src

  2. Edit ~/xterm-noclear.src

    • change the name on the second line from 'xterm' to 'xterm-noclear', or whatever suits you (also change 'xterm-debian' if it's present)
    • remove the instructions 'smcup' and 'rmcup' (e.g. "smcup=\E[?1049h, " and "rmcup=\E[?1049l, ")
  3. $ mkdir ~/.terminfo

  4. $ tic ~/xterm-noclear.src (x/xterm-noclear should appear in your ~/.terminfo directory)

  5. $ export TERM=xterm-noclear (now check the behaviour of less and, if satisfied, add the export directive line to your ~/.profile)

added 88 characters in body
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can tellprevent less not tofrom launch in an altscreen by passing the following the environment variableargument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may lookappear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success.

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can tell less not to launch in an altscreen by passing the following the environment variable "-X". So if you are using bash, place this in ~.bashrc:

export LESS="-X"

However, this disbles the termcap initialization and deinitialization, so other views when you use less may look off.

Another option would be to use screen and set the option altscreen off in your ~.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success.

This is actually a function of the terminal emulator you are using (xterm, gnome-terminal, konsole, screen). An alternate screen, or altscreen, gets launched when programs such as less or vim are invoked. This altscreen has no history buffer and exits immediately when you quit the program, switching back to the original screen which restores the previous window content history and placement.

You can prevent less from launch in an altscreen by passing the argument "-X".

less -X /path/to/some/file

You can also pass "-X" as an environment variable. So if you are using bash, place this in ~/.bashrc:

export LESS="-X"

However, this disbles the termcap (terminal capability) initialization and deinitialization, so other views when you use less may appear off.

Another option would be to use screen and set the option altscreen off in your ~/.screenrc. less will not clear the screen and should preserve color formatting. Presumably tmux will have the same option.

This blog entry describes the problem and offers some different solutions specific to gnome-terminal with varying success.

added 33 characters in body
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53
Loading
added 218 characters in body
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53
Loading
added 103 characters in body
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53
Loading
added 103 characters in body
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53
Loading
Source Link
George M
  • 14.3k
  • 4
  • 45
  • 53
Loading