How can I partially clear my terminal scrollback?

42

12

I want to partially clear my terminal scrollback history, but only from where I have selected with my mouse in the scrollback and up. Is this possible? I'm on a Mac, and I use iTerm2 and Terminal.

Javid Jamae

Posted 2013-04-01T16:01:03.820

Reputation: 548

1bash doesn't have any notion of scrollback; that's something your terminal emulator manages. – chepner – 2013-04-01T18:03:19.727

@chepner - ok, good point. I just reframed the question to not be about bash. – Javid Jamae – 2013-04-01T18:56:19.683

Answers

85

Not sure about partially, but you can fully clear your scrollback with Cmd+K. Control+L will only clear the screen, not the scrollback content/history/buffer.

If you want the partial scrollback badly enough, this would probably be the place to implement it.

Luqmaan

Posted 2013-04-01T16:01:03.820

Reputation: 965

1Thanks, but man, that is some nasty code! I don't think I'd ever want anything so badly that I would have to get in to that codebase. :-) – Javid Jamae – 2013-12-16T23:00:12.510

0

This is not possible, but you can clear just the screen by pressing Control+L.

Mark Stewart

Posted 2013-04-01T16:01:03.820

Reputation: 618

-1

This command will most probably give you the possible history files. You can open it in a text editor and edit.

ls -a ~ | grep hist

iozozturk

Posted 2013-04-01T16:01:03.820

Reputation: 1

Welcome to Super User! Please reread the question- OP is asking about scrollback, not history. – bertieb – 2018-05-04T13:11:19.207

-1

http://www.pendrivelinux.com/how-to-clear-the-terminal-command-history/

This will clear the history completely. history -c

No way I could find to do a partial.

Edwin Dover

Posted 2013-04-01T16:01:03.820

Reputation: 1

-3

If I have correctly understood your question, I think that you can achieve that by manually editing your history file, ~/.bash_history.

P.S.: In order to save your current session, you have to first close the Terminal.

dezzeus

Posted 2013-04-01T16:01:03.820

Reputation: 688

4No, I think you misunderstood. The .bash_history file is for the command history, not the terminal scrollback history. – Javid Jamae – 2013-12-16T22:54:52.447