Terminal – How to Open a Clean Terminal in Mac OS X Lion

osx lionterminal

Whenever I open a terminal, the last used commands appear.

I'd like to get a clean terminal when I open it, but I haven't found how to do it.

For example if while using the terminal I do:

defaults write com.apple.Finder...etc

and then I close the terminal. Next time I open the terminal I will see this same line grayed out (to indicate it's a command I used last time I opened the terminal) and a line to start writing underneath.

Best Answer

Add the following at the very end of .bash_profile:

printf '\033c'

This will really clear the Terminal. I even defined the following function, since I didn't like the scrolling behavior of the default clear:

function clear {
    printf '\033c'
}

I think it's the same as a hard reset of the Terminal (Cmd-Opt-R), but I'm not entirely sure.

Related Question