1

In the bash shell, using for example grep <pattern> <file> would result in every line containing the pattern to be returned and the pattern to be highlighted in red bold font in each of these lines. However, when I use !grep from the IPython shell, the pattern is not highlighted in the returned lines.

Similarly, from within the IPython shell, !ls does not produce colored or bold output, while ls does. Is there any way to enable highlighting in the output from magic commands in the IPython shell?

I am Ubuntu 15.04, using IPython 3.2.0.

joelostblom
  • 43,590
  • 17
  • 150
  • 159
  • Read `man grep`, search for `color`. – n. m. could be an AI Jul 21 '15 at 13:17
  • Try `grep --color=always` and `ls --color=always`. These should work for the `grep` and `ls` from gnu coreutils. – William Pursell Jul 21 '15 at 13:21
  • ah, I thought color was the default for `grep`, I didn't realize there was an alias set up automatically by Ubuntu in my `.bashrc`. So is there any way I can get IPython to respect my aliases, instead of passing the commands without any parameters? – joelostblom Jul 21 '15 at 17:19
  • I found [this](http://www.quora.com/How-can-I-make-IPython-import-the-aliases-defined-in-my-bash-profile-upon-startup), but maybe there is a simpler way? – joelostblom Jul 21 '15 at 17:20
  • [Many people](https://discourse.jupyter.org/t/bash-kernel-colors-for-stdout/6560/2) are wondering how to do this. – Scrooge McDuck Nov 22 '20 at 23:40

0 Answers0