You are not logged in.

#1 2008-02-29 09:58:15

niller
Member
From: Denmark
Registered: 2008-02-12
Posts: 91

Clear screen automatically, how to do this ?

When closing a CLI program the command prompt always appears in the middle of the screen.

How do I avoid that ??

I have a alias cls='clear' in my .bashrc, but how do I make it so the screen clears every time when closing a program ??


/Niels
Registered Linux user #133791
Get counted at http://counter.li.org

Offline

#2 2008-02-29 10:52:13

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: Clear screen automatically, how to do this ?

Hi,

I thought a bit about it, normally you would use bash's PROMPT_COMMAND, but clearing the prompt after every command would be a bit counter productive. You could use the following small function in your .bashrc though:

clearprompt() {
    eval $1
    clear
}

And then just set an alias in your .bashrc for the cli app you want the prompt to clear after its executed, for example:

alias top="clearprompt /usr/bin/top"

you have to use the full path to the command in the alias when you want to give the alias the same name as the command itself otherwise bash segfaults. It's probably a dirty hack I know wink.

HTH

Last edited by chimeric (2008-02-29 10:53:56)

Offline

#3 2008-02-29 11:21:46

niller
Member
From: Denmark
Registered: 2008-02-12
Posts: 91

Re: Clear screen automatically, how to do this ?

Argh come on' !!

There must a more proper way to do this big_smile


/Niels
Registered Linux user #133791
Get counted at http://counter.li.org

Offline

#4 2008-02-29 12:00:47

veek
Member
Registered: 2006-03-10
Posts: 167

Re: Clear screen automatically, how to do this ?

What terminal are you using? Also can you give an example of a program that causes this?
I mean does it happen when you view a man page and then exit?

I'm using urxvt and exiting from vim, rtorrent, a man page etc., I don't have this problem.

Offline

#5 2008-03-01 12:57:51

niller
Member
From: Denmark
Registered: 2008-02-12
Posts: 91

Re: Clear screen automatically, how to do this ?

I'm using urxvt, but since I can't reproduce this i think it is related to xmonad (my wm) sad


/Niels
Registered Linux user #133791
Get counted at http://counter.li.org

Offline

#6 2008-03-01 15:32:43

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: Clear screen automatically, how to do this ?

I think you should find a proper fix instead of clearing the screen when each command exits. How will you ever read the output from ls or find without piping it through less or redirecting it to a file?

Have you changed your prompt? Sometimes that can cause weird behaviour

Last edited by dmartins (2008-03-01 15:34:12)

Offline

Board footer

Powered by FluxBB