# Execute each command in terminal from top line / Execute clear before each command [duplicate]

I would like to ask if it is possible to set up in bash so that each command is executed from of the top of terminal window. In other words if it is possible to execute clear before each command.

Also I wonder if it is possible to do this without using preexec() hook since I have history disabled anyway in bash.

## marked as duplicate by αғsнιη, Scott, Romeo Ninov, Jeff Schaller♦, ArchemarJul 30 '17 at 13:22

• Out of interest, why would you want to do this? Any command with any kind of output would be moot, e.g. ls. – Sparhawk Mar 14 '17 at 2:23
• Put ^[[2J^[[;H at the beginning of PS1, and bask in the inability to see the output of any of your commands. (Note: ^[ indicates a literal Escape) – DopeGhoti Mar 14 '17 at 2:35
• or just do PS1=clear ; very effective – Rui F Ribeiro Mar 14 '17 at 2:54
• A cat with many skins, POSIX be. – DopeGhoti Mar 14 '17 at 3:36
• Not exactly the same, but related and more useful: Keep bash input on top line of screen – Gilles Mar 14 '17 at 23:35

export PROMPT_COMMAND="clear; $PROMPT_COMMAND"  According to the Bash manual: PROMPT_COMMAND If set, the value is interpreted as a command to execute before the printing of each primary prompt ($PS1).