Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Following my question from long ago, I am still trying to tweak my fortune handling capabilities. The display in terminal is awesome, just one thing remains - syntax highlighting in Gedit as I add, edit or delete individual fortunes.

My custom fortune files are in this format:

Friend: "Whats a good movie?"
Me: "Snakes on a plane"
Friend: "Whats it about?"
Me: "Horses... horses on a boat..."
Me on my wedding: you still like me, right?
Mum: Son I'd love to meet your girlfriend...
Me: Me too...
Doctor: "Ok, so what's wrong, how are you feeling?"
Me: *Looks at mum waiting for her to explain*
Friend: 75% of people are good at maths...
Me: Mmmmh, I guess then am in the remaining 18%...
I loved the Titanic. My favorite character was the iceberg

It's basically a tweet, @name and the % character. Then repeat.

When I open it in Gedit, everything is black.
I'm looking for a way to create a syntax highlighting file that will convert the % to something like blue and the @name to something like magenta. The tweet can remain black.


  1. The fortune files are mime-type text/plain and only the given format really distinguishes them from another plain text file.
  2. Fortune files have no extension.
share|improve this question
up vote 6 down vote accepted

Create and open your fortune language file:

sudo touch /usr/share/gtksourceview-3.0/language-specs/fortune.lang
sudo -i gedit /usr/share/gtksourceview-3.0/language-specs/fortune.lang

Paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<language id="fortune" _name="Fortune" version="2.0" _section="Markup">
    <property name="mimetypes">text/plain</property>
    <property name="globs">*.</property>

    <style id="at"      _name="@ sign"  map-to="def:constant" />
    <style id="percent" _name="percent sign"  map-to="def:comment" />
    <context id="fortune">
        <context id="at" style-ref="at">
        <context id="percent" style-ref="percent">

Make sure it is accessible:

sudo chmod 0644 /usr/share/gtksourceview-2.0/language-specs/screenplay.lang

Restart gedit.

Reference - my source answer

share|improve this answer
Thanks alot, will try this out. One thing though, fortune files have no extension, the reason for the text/plain mime type. Does that mean <property name="globs">*.fort</property> becomes <property name="globs">*</property>? – Parto May 28 '14 at 4:39
@Parto That would apply it to all files with no extension, but as most are .txt that would be fine. Change it to <property name="globs">*.</property>, and I've updated the answer with this! – Tim May 28 '14 at 9:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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