[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: Screen clear on terminal logout (was Re: Orphaned User Accounts?)



----Original Message----
From: Bob Proulx [mailto:bob@proulx.com]
Sent: Wednesday, November 03, 2010 11:35 AM
To: debian-user@lists.debian.org
Subject: Re: Screen clear on terminal logout (was Re: Orphaned User
Accounts?) 

> James Zuelow wrote:
>>> Carlos Mennens wrote:
>>>> I always wanted to tell them I hate the fact that when 'root' logs
>>>> out, the terminal / bash window doesn't clear like it does for
>>>> normal 
>> 
>> Here's a workaround.  This will clear the screen for all users:
>> 
>>  mv /etc/issue /etc/issue.original
>>  clear > /etc/issue
>>  cat /etc/issue.original >> /etc/issue
> 
> Except that clears the screen on login, not logout.  It would have
> effect on a hardware terminal since a logout there is usually followed
> by the login prompt.  

Sorry, my bad.  Since getty respawns as soon as you log out, it effectively clears the screen as soon as you type 'exit', so that is what I use it for.

But you're right, it only works for the local display.


>But it won't have effect for any network access.

The only network access I typically do is ssh, and when I'm done I just close the konsole window.  If I am working from a console I could just type `clear` when I'm done if I want to clear the screen.  (Or, I log out and let my /etc/issue trick clear it for me.)  I don't see how the remote machine could clear my local display.

However there's always a way.  You could use a .bash_logout on the remote machine to clear the screen:

1) .bash_logout has one line:

    /usr/bin/clear

Or if for some reason you can't do that, you can do it locally with an alias in .bashrc:

1) make a small bash script, /usr/local/bin/autoclear_ssh.sh:
     #!/bin/bash
     ssh $@ && clear

2) make an alias in your .bashrc:
     alias ssh='/usr/local/bin/autoclear_ssh.sh'

3) Profit!!!

Then when you ssh to a server, the display will clear when you're done.

It's not perfect though, because if you send ssh a command that terminates right away like `ssh 192.168.1.1 ls` the script will clear the screen before you see your ls output.  The .bash_logout is probably better.

There's got to be a zillion ways to do it.

James Z

Reply to: