Is it possible to process/transform the output from grep (or produce grep-like results, finding strings and/or patterns in files, some other way) such that the search results can be used as links (i.e., hyperlinks) to open an editor?  I want to click on a filename:line_number in my grep result and open my editor at the selected line.

$ grep "mServiceIntent" -R ./src/
./src/example/PhotoThumbnailFragment.java:67    private Intent mServiceIntent;
./src/example/PhotoThumbnailFragment.java:194        mServiceIntent =
./src/example/PhotoThumbnailFragment.java:203        getActivity().startService(mServiceIntent);

I know how to register protocols in the system to open the editor.  For example, all URLs like sblm://* in my system open in Sublime Text.  My question is: how to create custom links in guake terminal (or maybe it doesn't depend on quake and works for default terminal program)?

Note: the related(?) question, Is there a terminal app that allows filenames to be clickable?, is vague on specific implementation/solution details, and doesn't explicitly mention my requirement to jump directly to an identified line in the file.


2 Answers 2


Newer version of GNOME terminal now support hyperlinks with custom target via certain escape sequences. Try

echo -e '\e]8;;http://example.com\aThis is a link\e]8;;\a'

Opening these works the same way as described in the answer by Stephen Kitt. To address the problem you described you could use a sed script (or some more advanced method) to translate the file names into hyperlinks. For me the following does the job (in bash and assuming the above way to create hyperlinks works)

grep "mServiceIntent" -R ./src/ | sed -e $'s#^\(.*\):#\e]8;;file:'`pwd`/$'\\1\a\\1\e]8;;\a#'

(I do not have sublime installed but most likely you can simply change file: into slbm:)

See also: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda (This is based on my answer at Terminal - create hyperlinks)


It's a computer; you can program it. :-)

To make something "clickable" means either programming a GUI application or somehow using HTML. The simplest way I can think of would be to generate an HTML page of HREFs, and pipe the output to, say, lynx, configuring the browser to open emacs appropriately.

  • 7
    This does not answer the question as asked - he does not want to reinvent the wheel by creating an entirely new terminal GUI.
    – dykeag
    Commented Aug 5, 2020 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .