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.
-
1`bash` doesn't have any notion of scrollback; that's something your terminal emulator manages. – chepner Apr 01 '13 at 18:03
-
@chepner - ok, good point. I just reframed the question to not be about bash. – Javid Jamae Apr 01 '13 at 18:56
-
3Landed here from a search for fully clearing scrollback. If you need to fully clear scrollback, `right-click` -> `clear buffer` – Shamal Karunarathne Jan 12 '21 at 20:54
5 Answers
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.
- 1,335
- 1
- 9
- 8
-
2Thanks, 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 Dec 16 '13 at 23:00
-
If this is still true - and it seems it is - that's very disappointing. The scrollback buffer looks like a trash dump, picking up bits from the pager & randomly over-writing stuff that might actually be useful. – Seamus Mar 30 '22 at 23:30
This is not possible, but you can clear just the screen by pressing Control+L.
- 21,399
- 46
- 64
- 121
- 768
- 1
- 6
- 11
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.
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
-
Welcome to Super User! Please reread the question- OP is asking about scrollback, not history. – bertieb May 04 '18 at 13:11
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.
- 21,399
- 46
- 64
- 121
- 846
- 8
- 9
-
6No, I think you misunderstood. The .bash_history file is for the command history, not the terminal scrollback history. – Javid Jamae Dec 16 '13 at 22:54