LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   terminal window view after quitting an editor (https://www.linuxquestions.org/questions/linux-general-1/terminal-window-view-after-quitting-an-editor-791587/)

alumni 02-25-2010 04:36 PM

terminal window view after quitting an editor
 
Hi all,

I am using CentOS release 4.7 and tcsh shell.

Here is a description for the issue:
1-I telnet to my linux machine
2-list some directories
3-then I open an editor from the command line (e.g. vim or emacs)
4-And then quit the editor after I am done
5-Once I quit, I am back to the shell prompt (command line)


My question is regarding what the terminal window shows after quitting the editor. It can either:
1-show you the same contents it was showing before launching the editor (the directory listings I've done before launching the editor)
2-Or it shows you the prompt (command line) at the bottom and above it is a view of the file that was being edited.

I am seeing the second behavior but I want to have the first behavior. I've been searching for several hours for a hint with no luck.

Thank you

MTK358 02-26-2010 09:26 AM

I think that depends on what terminal application you are using. Most GUI terminal emulators seem to detect an ncurses app (like most editors) and switch to a special mode. But the second behavior happens for me when in command-line mode (no GUI).

I am not sure if that can be "fixed", but you were saying that you wanted to see a dir listing above. Can you just use the up arrow key to find the command that created the listing an run it again?

alumni 02-26-2010 11:42 AM

Quote:

Originally Posted by MTK358 (Post 3877866)
I think that depends on what terminal application you are using. Most GUI terminal emulators seem to detect an ncurses app (like most editors) and switch to a special mode. But the second behavior happens for me when in command-line mode (no GUI).

I am not sure if that can be "fixed", but you were saying that you wanted to see a dir listing above. Can you just use the up arrow key to find the command that created the listing an run it again?

Thank you for the response.

I tried both terminals:
1-Putty.
2-Linux terminal launched from Linux GUI.

I sure can use the up arrow to repeat the last command in history.

The reason why I am asking how to have the first behavior is that I've had it in the past on a different machine but do not know what is the difference that is causing such different behaviors.

MTK358 02-26-2010 12:27 PM

Is it always behavior #1 on Linux terminal and always #2 on Putty? Or is it the other way round?

alumni 02-26-2010 06:43 PM

Quote:

Originally Posted by MTK358 (Post 3878018)
Is it always behavior #1 on Linux terminal and always #2 on Putty? Or is it the other way round?

In fact it is always behavior #2 with both: Linux terminal from within Linux GUI or putty (telnet to the Linux machine).

Also, it the behavior is identical with emacs and vim (command line based editors).

Can you please help me rule out one of the potential reasons for behavior 2:
A-Is it a shell issue?
B-Is it an editor issue?

Thank you,

MTK358 02-26-2010 07:09 PM

It's neither of those two.

It's a terminal emulator issue. Actually it isn't an issue, because that's the way it's supposed to work.

As I understand, many terminal emulators detect if an app uses ncurses (Google if you don't know what it is), and if so, enters a special mode, and then returns to the original mode when the program exits. I'm not sure how it works if if that's really the way it works, though.

alumni 03-04-2010 08:47 PM

Quote:

Originally Posted by MTK358 (Post 3878355)
It's neither of those two.

It's a terminal emulator issue. Actually it isn't an issue, because that's the way it's supposed to work.

As I understand, many terminal emulators detect if an app uses ncurses (Google if you don't know what it is), and if so, enters a special mode, and then returns to the original mode when the program exits. I'm not sure how it works if if that's really the way it works, though.


Hi,

I figured out why the two behaviors are different and how to switch in between them.

The behavior depends on the terminal emulation used on the Linux box (xterm, screen, ansi, etc).

The first behavior shows when using xterm terminal emulation on Linux. This means that TERM environment variable is set to "xterm".

The second behavior shows when using ansi terminal emulation on Linux. This means that TERM environment variable is set to "ansi".

To switch from the second behavior to the first:
1- Edit your .cshrc (assuming the use of csh)
2- Add the following line at the bottom:
setenv TERM "xterm"
3- source .cshrc
4- Give it a try

Thank you for your responses.
Cheers


All times are GMT -5. The time now is 12:39 PM.