Grep Console How-to #7: Rewriting Lines

As of Grep Console 3.3, lines filtered to the Grep View can be rewritten. For example, information from your log4j output that’s irrelevant during development could be removed. Or if you put some keywords in your debug output solely to have something for Grep Console to recognise, you could strip that from your Grep View output. These rewritten lines are not subject to the standard styles applied by Grep Console via regular expression matching. Instead, you can specify the styles for your rewritten lines directly.

Simple rewriting

Let’s say you have log4j prefix your error messages with the string [ERROR]. You want to filter those lines to Grep View, and you want to highlight them with a red background. But since you’re highlighting them, there’s no reason to keep the [ERROR] tag, so you want to filter that out.

This is easily done. We’ll start with an expression that matches your error lines:

\Q[ERROR] \E(.*)

This captures strings starting with the [ERROR] tag followed by a space and any number of additional characters. These additional characters are also marked as a capture group, because we still need them for our rewritten line.

Now we can add a rewrite expression. In this case, it’s simple – we only want to output the content of our capture group, so the rewrite expression looks like this:


After entering the rewrite expression, the style/link table will show an additional line labelled Whole rewritten line, which we can use to assign a red background to our rewritten line:

Simple rewriting settings

And here’s some sample output, with the regular console on the left and the Grep View output on the right:

Simple rewriting result

Styles and links

We don’t have to base the visible content of our rewritten line on the original console output. For example, if our application writes lots of very long HTTP links to the console, we actually might decide to not display the URLs, and instead just show a short text with a highlight and a clickable link that opens the URL in a browser.

A regular expression for this scenario might look like this:


This matches strings starting with the prefix http:// followed by any number of non-whitespace characters. This whole URL is marked as a capture group.

We’ll replace the entire line with a simple string via the following rewrite expression:

Click (here)

Note that we’ve marked the word “here” as a group in the expression. This adds yet another line to the style/link view, labelled Rewritten group 1:

Links settings

We can use this group to assign a highlight style to the word “here”. And we’ll add a link of type URL, using {1} as the link’s URL. This will use capture group from the regular expression as the link target – and that capture group contains exactly the HTTP link from the original line.

This is what our rewritten line looks like when holding the CTRL key and hovering the mouse cursor over the link:

Links result


Posted in Grep Console | Tagged , | Leave a comment

Grep Console How-to #6: Autostart Links

Grep Console 3.2 introduced links which can be clicked to perform specific actions, like opening an Eclipse editor or a web browser (see the previous how to for an introduction to links).

Expanding on this concept, Grep Console 3.3 adds autostart links. An autostart link is not clickable. It’s not even displayed. Instead, the link’s action is simply executed whenever a line matching its expression is written to the console.

Update 2013-06-30: As of Grep Console version 3.5, autostart links have been renamed to autostart actions and moved to the notifications tab.


In the expression dialogue, an autostart link can be configured on the left side, below the preview panel:

An autostart link can be configured on the left side, below the preview panel.

Of course, the same link can also be set on a capture group or the whole line if you also want it to be able for manual clicking.

Autostart links are a feature of Grep View filtering and only work if the expression is enabled for filtering.


Say I have a JUnit test case which starts an HTTP server and does some testing on it before shutting down the server again. Sometimes I want to have an actual look on the server before the test’s clean up code is executed. So I’ll log the address of my server to the console and set a breakpoint before the clean up part.

If my log output looks like this…

Server URL: http://localhost:8080/my/test/page

…I can set up a regular expression like this…

\QServer URL: \E(http\:\/\/\S+)

…to capture (and perhaps highlight) the line.

I can then configure an autostart link of type URL for this expression and use {1} as the URL to automatically open the capture URL whenever my test case outputs this line.

Posted in Grep Console | Tagged , | Leave a comment

New Grep Console release: 3.3

Hot on the heels of last week’s 3.2.1 release, Grep Console 3.3 is out, providing new features and several bug fixes.


  • Original line styles may now be kept even if custom styles are applied to a line.
  • All dialogues now feature help links. Thanks to Angel Ezquerra for suggesting this feature.
  • Autostart links – Each expression can specify a link which is executed automatically when a matching line is written. Requires the Grep View to work.
  • Grep View line rewriting – Lines filtered to the Grep View can now be rewritten. Rewritten lines can include any parts of the original line and may have different styles and links than the original console output. Thanks to Didier Grzejszczak for suggesting this feature.

Bug fixes:

  • Grep View pattern matching – completely broken in the previous release. Thanks to Matthias Scholz for reporting this bug.
  • Fixed NullPointerException for matches with unused groups. Thanks to Christian Afonso for reporting this bug.
  • Settings are now saved correctly when the Grep Console dialogue is opened from the CDT build console. Thanks to Angel Ezquerra for reporting this bug.

For installation instructions, please see here. As always, feedback is welcome.

Posted in Grep Console | Tagged , | Leave a comment

Bugfix Release: Grep Console 3.2.1

Version 3.2.1 of Grep Console is out, fixing the following bugs:

Performance issues with regular expression matching. Changes in the matching code lead to serious performance problems for some users. Some modifications in the matching function should hopefully fix that. Thanks to Michaël Clavier and “Jordi” for reporting this bug.

Unmatched lines are no longer set to the default style. Previously, lines that did not match any expressions were nevertheless set to the default font style, overriding font colours set in the console preferences. Thanks to Angel Ezquerra for reporting this bug.

Posted in Grep Console | Tagged , | Leave a comment

Grep Console How-to #5: Links

One feature I had been considering for Grep Console for a while was customisable links in the matched text lines. For example, HTTP hyperlinks could be rendered as links and open the browser when clicked. I abandoned the idea when I couldn’t figure out how to put links in the console and didn’t want to hold up the original release of version 3 even longer. Recently I got an email requesting a feature just like this, so I delved a little deeper into the Eclipse APIs, and the result is the newly release version 3.2 with link support.


Links, like styles, can be assigned to whole lines or capture groups. This is done in the style assignment table in the expression dialog, which now features a column for the links:

Edit expression dialog Double clicking a cell in the link column will open a dialogue that can be used to edit the link for the corresponding group. The dialogue shows a combo box allowing you to select between “no link” and various types of links – see below for details. The rest of the dialogue content changes depending on the selected link type:

Edit link dialog

Also, right clicking on a link cell in the style/link assignment table lets you copy and paste links.


Links don’t make a lot of sense if they are static and always link to the same target regardless of the text they have been matched to, so most fields for the various types of links are so-called patterns which allow you to use parameters to insert portions of the matched text.

As an example, an expression that matches strings starting with “www” could use a link of type URL wih the following URL pattern parameter to open the corresponding website:


The following parameters are available in patterns:

{line} – The whole line text string of the matched line.
{match} – The whole matched text.
{group} – The text of the matched capture group.
{1}, {2},… – The text of the specified capture group.

Using links

In order to not interfere with normal cursor positioning in the console, Grep Console don’t automatically react when clicked on. They also don’t have a specific style of their own – each link is assigned to a group in its expression, so the same group can be assigned any style you like to highlight the link. To actually “open” a link, i.e. to execute the behaviour associated with it, hold down the CTRL key and click on the link. Hovering over a link with CTRL held down will turn the mouse cursor into a link cursor and show a tooltip for the link.

File links

A file link points to a file in the file system and opens it in an Eclipse editor when the link is clicked. An optional line number parameter can be used to position the cursor in a specific line.

For example, the following expression can be used to find text file references with line numbers like “/home/myuser/myfile.txt:42” in the console:


The first group matches a string of non-whitespace characters ending with “.txt” directly before a colon, while the second group matches a series of digits directly after the same colon.

File link

For this expression, a file link can be configured to use {1} (the first capture group) as the file name and {2} (the second capture group) as the line number.

Java type links

Similar to file links, Java type links open any type from a Java project in an Eclipse editor. The types must be referenced by their fully qualified name and be in the same project that is associated with the launch configuration connected to the console.

If the classes in your project belong to the namespace com.myproject, the following expression can be used to find references like “com.myproject.MyClass:42” in the console output:


Java type link

Like the example in the file link section, the first group captures the fully qualified class name, while the second group captures the line number. Use {1} for the Java type and {2} for the line number field in the link settings.

URL links

Links can be opened internally in an Eclipse browser, or externally in whatever application the operating system deems appropriate for the link. Usually this will be the system browser, but depending on the prefix and file extension, any kind of application (e.g. an FTP client or an image editor) may be associated with a link.

The following expression will match all links starting with “http://”:


URL link

With this expression in place, a URL link with {match} as its URL pattern can be configured. Use the checkbox below the URL field to specify whether the link should be opened internally or externally.

Command links

If opening files and URLs is not enough for you, you can use command links to call system or shell commands. For example, to open image files with the image viewer Gwenview, you can use the following expression to capture all PNG file names in the console:


Then a command link with the following command pattern will open the viewer when the link is clicked:

gwenview {match}

Command link

For commands where the working directory matters, you can control it with a separate field. If the working directory is not specified, Eclipse’s own current working directory is used.

Script links

With this link type, you can execute scripts directly in your Eclipse environment. The scripts are executed via the Java Scripting API and can be written in any language installed for the Java Scripting API in your Eclipse setup. Out of the box, the API supports Javascript.

A drop down box in the link dialog allows you to pick one of the available languages. This list is queried from the Scripting API, and since some language modules offer several alternative names for the language they support, the drop down list may include multiple entries for the same language. For example, “Javascript” will also show up as “js”, “rhino”, “javascript”, “ECMAScript” and “ecmascript”.

The code box lets you enter script code in the selected language. The script code doesn’t use pattern parameters, but the script can access the expression match information in a number of variables passed to it upon execution. These variables are listed a tooltip text which appears if you leave the mouse cursor hovering over the code box for a few seconds.

Scripts executed via the Java Scripting API have full access to the entire Java API and all libraries in the class path (see below). Here, I only provide a simple example that prints the matched line of text to stdout:


Script linkA note on the class path: In Eclipse, each plug-in has its own class loader, and therefore its own class path. Scripts run from Grep Console therefore have access to all the classes that the Grep Console plug-in itself  has access to. Classes from other, unrelated plug-ins are not accessible, and neither are the classes from your project producing the console output.

Posted in Grep Console | Tagged , | 9 Comments

New Grep Console release: 3.2

A new version of Grep Console is out, with new features and a bug fix.

Edit link dialog


  • Multiple matches per line – Expressions may now match multiple substrings per line. Previously, only the last match in a line was recognised. Thanks to Tiogshi Laj for suggesting this feature.
  • Links – Expressions and capture groups may now be assigned links. These links will be executed when the matched substring is clicked on while the CTRL key is pressed. Different link types can be used to open text files or Java types in the Eclipse editor, open URLs in a browser or execute scripts and system commands. Thanks to Angel Ezquerra for suggesting this feature.
  • Pattern help – The expression dialog now contains a web link to the Java Pattern API documentation (explaining the regular expression syntax).

Bug fixes:

  • Configuration XMLs were exported using a wrong encoding on Windows. Thanks to Tiogshi Laj for reporting this issue.

For installation instructions, please see here. As always, feedback is welcome.

Posted in Grep Console | Tagged , | 3 Comments

Fixed a link on my Eclipse update site

Just in case anyone has had trouble installing the 3.x version of Grep Console, I’ve fixed a link on the update site. Before the fix, the link on that page pointed to the old update site which, when entered in Eclipse, would only install the old 2.x version of Grep Console. The link is corrected now. If you’re stuck on version 2.x, or if the update site in your Eclipse is “” instead of “”, please update to the correct link found here.

If you copied the update link site directly from the installation page, or if you used any of the download links there or in Eclipse Marketplace, you should have had the correct version all along. No need to do anything in this case.

Thanks to “Glen” for pointing out this error.

Posted in Grep Console | Tagged , , | 1 Comment

New Grep Console release: 3.1.1

A new version of Grep Console is out. Compared to the previous version, there are a few new features and bug fixes.


  • “Unless” expressions – An optional second regular expression can be configure for each item to prevent the item from being considered a match for certain strings even if the main expression matches. Thanks to Christian Afonso for suggesting this feature.
  • Case sensitivity – Case sensitivity of grep expressions can now easily be toggled via a checkbox. Thanks to “Tom” for suggesting this feature.
  • Jump to line – The Grep View context menu now provides an action for jumping to the selected line in the original console.
  • Support for more run configurations – The Grep Console tab is now available for JUnit, Eclipse RCP and CDT launch configurations.

Bug fixes:

Fixed null pointer issues in Eclipse 4.2 on Windows 7. Thanks to Mark Harkin and Didier Loiseau for reporting this bug.

  • Fixed item tree column sizing in Eclipse 4.2.
  • Item tree now uses the correct system text colours for selected and deselected lines. Thanks to “Bill” for reporting this bug.
  • Fixed a resource leak that would create too many style preview images, causing the system to run out of handles.
  • Fixed handling of non-standard line delimiters. Previously, lines that ended with non-standard delimiter characters would not be parsed correctly.

For installation instructions, please see here. As always, feedback is welcome.

Posted in Grep Console | Tagged , | Leave a comment

Fixing pulseaudio issues on Ubuntu 12.10

After a long hassle with varying sound libraries over the years, I’ve been relatively happy with how pulseaudio turned out for a while now. It still has its quirks, but it’s been mostly working fine for the last few versions of Ubuntu, and some of the configuration features are really useful. I’m using my onboard sound card for system sounds and an SB Live! for music and video, and pavucontrol makes it easy to permanently redirect different applications to specific cards.

Or at least, I’d been relatively happy until I updated to Ubuntu 12.10 a few weeks ago. Suddenly, sounds played through KDE’s Phonon would sound garbled for at least several seconds. mplayer and other tools that don’t go through Phonon sounded fine, but KDE system sounds and Amarok’s music output would be horribly distorted. Jumping around in the audio stream a few times would fix Amarok’s output (until playback stopped and I hit the play button again), but that didn’t really make me happy.

This bug report provided the solution (reply #23 to be exact).

Turns out the current version of pulseaudio seems to have scheduling issues with some broken Alsa drivers, and those drivers apparently include those for the SB Live!. A pulseaudio module parameter fixes the issue.

In /etc/pulse/, change this line:

load-module module-udev-detect


load-module module-udev-detect tsched=0

This switches pulseaudio to the older scheduling mode and gets rid of the glitches.

Posted in Linux | Tagged , , | 5 Comments

Grep Console Screencast

Ashutosh Jindal has posted a nice video introduction to Grep Console (version 2) on YouTube:

Posted in Grep Console | Tagged , | Leave a comment