Is it possible to clear the command window of gdb? I mean, is there a command in gdb that do the same (for the command windows) as the clear
command in a bash terminal?
Asked
Active
Viewed 2.9k times
3 Answers
80
Hit Control + L
. Works for me in Linux and Mac OS X as well with recent versions of GDB.
-
1Actually, this works in a terminal as well. Moreover, it works in a *Cygwin* terminal, which doesn't have a `clear` command. Hence, a good habit to get into. ;-) – DevSolar Oct 17 '12 at 15:43
-
1@JohnTortugo you must be using some insane environment. – Oct 17 '12 at 15:46
-
@H2CO3 also doesn't work under OSX/xterm, fairly vanilla setup – pb2q Oct 17 '12 at 15:46
-
@H2CO3: I assumed *you* know that. I just thought I'd mention this for other readers. – DevSolar Oct 18 '12 at 08:09
-
@JohnTortugo: Using Ctrl-L to clear the screen is a feature of the shell, not of the terminal emulator. (The shell has to know what control sequence to use; that's what `terminfo` is for.) – Keith Thompson Jun 09 '15 at 00:40
-
Control L doesn't clear the screen. It shifts the screen up so that the last line is at the top. The answer from pd2q that has "shell clear" actually clears the screen. – UKMonkey May 21 '21 at 08:22
57
Depending on the environment you can try this key combination: Ctrl+L. That is: hold down the Control key, and type the L key.
But this may not work in all environments. You can also try the following: in gdb you can execute shell commands using shell
: use this to call out to the shell to clear the terminal:
shell clear

pb2q
- 58,613
- 19
- 146
- 147
-
1
-
1
-
@JohnTortugo I can't test that, but it sounds like you need to tweak your `TERM` setting – pb2q Oct 17 '12 at 15:48
-
@JohnTortugo play around w/ TERM settings under gnome-term and you should be able to use it there as well. – pb2q Oct 17 '12 at 15:49
-
-
-
You are right this one always works for me. Ctrl + L may fail some times. e.g. clearing TUI outputs. – Vraj Pandya Oct 23 '16 at 02:49
-
@pb2q I'm using gbd in Windows 7 cmd (via MinGW). ctrl+ L is not clearing the screen. Any idea how I should to it on windows ? – Jason Krs Dec 24 '16 at 12:05
-
@JasonKrs, ```shell cls``` will do the job. On MinGW gdb seems to have cmd.exe as shell. – Serhii Kheilyk Mar 24 '17 at 14:20
-
1Can I do it in such a way that my registers and assembly TUI layouts are still visible? I only need to clear the cmd part of gdb. Ah, found it, leaving this comment here as the question might assume my use case as well (when looking at the title). https://stackoverflow.com/questions/42282955/how-to-clear-console-in-gdb-while-in-tui – Melvin Roest Feb 29 '20 at 17:40
0
If you downloaded gdb from MingW your cmd.exe seems to be known as shell, therefore to clear the command screen you need to use this command instead
shell cls

aan
- 1