Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I make terminal applications immune to terminal emulator close, but still able to use all virtual terminal features?

\begin{UPDATE}

I want my terminal application remain alive and accessible if I accidentally close terminal emulator. This functionality is provided by screen and tmux, but they have issues with colors and they flush screen. Yes, I can run the shell inside screen, but I do not want the shell remain alive unless there is some other program running.

\end{UPDATE}

I see this must be something like screen, but without VT100 terminal emulation, something which will just apply whatever application does with "terminal proxy"'s terminal (like outputting something to stdout/stderr or using stty to set terminal options) to the terminal this proxy runs in.

// I know about screen and altscreen on, but it makes either this (screen with TERM=screen):

screen with TERM=screen

or this (screen with TERM=rxvt-unicode):

screen with TERM=rxvt-unicode

while I want this (rxvt-unicode without screen):

rxvt-unicode

I have figured out that everything looks fine if I compile rxvt-unicode with USE=-xterm-color (in fact vim looks like on the second picture even without screen if I add this USE flag) and set TERM=screen-256color, but I do not like this workaround because it actually changes colors and I can't be sure that it will always change them only this way:

screen with TERM=screen-256color

share|improve this question
    
It's not clear what you're trying to do. What do you mean by "immune to terminal emulator close"? Do you simply want to disable certain terminal control codes? You can simply use infocmp, edit the capability and then use tic. –  Dennis Williamson May 26 '10 at 13:03
    
I want my terminal application remain alive and accessible if I accidentally close terminal emulator. This functionality is provided by screen and tmux, but they have issues with colors and they flush screen. Yes, I can run the shell inside screen, but I do not want the shell remain alive unless there is some other program running. –  ZyX May 26 '10 at 13:11
    
I stopped using rxvt-unicode because I could never get the colors to work right and some basic control characters caused rxvtu to display characters all over the place. Apple's Terminal.app and Gnome.terminal haven't given me any problems, however. I'm using the en-US character or UTF8 character sets. –  Stefan Lasiewski Jun 2 '10 at 22:21
    
@Stefan Lasiewski colors work just fine in rxvt-unicode; but they work just fine only in this terminal and only under certain conditions. If I switch to another terminal I would have to do something with them. Using LANG=ru_RU.UTF8. What do you mean by «display characters all over the place»? If it spoils the lines, try doing stty onlcr. –  ZyX Jun 3 '10 at 1:10
    
for me it is still unclear what " Yes, I can run the shell inside screen, but I do not want the shell remain alive unless there is some other program running" means. lets say tmux: tmux launches a shell and then you type there "yourprogramname" .. and you want the shell process to disappear, so its not tmux->shell->yourprogram anymore but tmux->yourprogram? if so, launch your program with "exec yourprogramname". –  akira Jul 6 '10 at 10:22

4 Answers 4

up vote 2 down vote accepted

There is also a program called "dtach" that does just that, without superimposing its own screen buffer. (I know the answer is quite late but I post it nonetheless for those who google and stumble upon the page)

share|improve this answer
    
No, it is not. Thanks, dtach works just like I want. –  ZyX Jan 17 '11 at 17:51

Yes, I can run the shell inside screen, but I do not want the shell remain alive unless there is some other program running.

One solution would be to run the shell from screen (as you said you didn't want to), but then add a Cron job to run every 10 minutes to check if there are screen sessions to close.

If all screen sessions are detached and no programs besides shells are running from them then you can close them down.

share|improve this answer
    
I am not afraid of adding another cron job, but this has nothing to do with colors. –  ZyX Jun 3 '10 at 1:02

Use sakura. It prompts you if you try to close a vterm down with a running program.

share|improve this answer

You can use screen to directly launch your application so when your app exits screen will exit:

screen <yourprog>

See the 5th paragraph of the screen manpage for more details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.