I am using a .gdbinit file to extend and prettify my gdb. The file uses escapes to colorize gdb which makes gdb look like this: gdb in console

Mostly I am using gdb with gud in emacs. Unfortunately gud is not resolving the escapes to a colored output, so I get something like that: gdb in emacs gud

It would be great to have the same output in gud as in console. Anyone an idea how I can achieve this? I searched the web but couldn't find anything in thi direction. Thanks a lot in advance.

1 Answer 1


This is working as expected, because Emacs is not a terminal emulator. You can add some support for these basic escape sequences to it if you want, but be aware that GUD also parses the output to look for source file names and line numbers (and perhaps more). You might be better off removing the escape sequences instead, to ensure that it can parse the buffer correctly. You could instead use Emacs's own syntax highlighting features to colorize the buffer. You might also prefer M-x gdb.

As you will find if you do even the most cursory search of the previous questions on this site, you can turn the ansi color escape sequences into actual color in anything based on shell-mode by adding this code to your init file:

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-to-list 'comint-output-filter-functions 'ansi-color-process-output)
  • I knew about the shell mode, just hoped I can do something compareable in gud. I decided to not use my config file in gud and configure gud instead, thanks. Feb 7 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.