The fortune utility remains one of my favorite programs (after all, it’s the name of this blog 🙂 ). The random quotes are a refreshing reminder not to take myself too seriously. But since I’ve been using byobu and GNU Screen, I rarely see the fortune cookie when my shell starts.
But then I realized what I really wanted was to see fortunes in Emacs. Fortunately, there is a package,
fortune.el, included in Emacs which provides a front-end to the fortune program. When invoked with
M-x fortune it throws the cookie into a new buffer and makes the new buffer active, which is slightly annoying.
What would be better would be to display the fortune in the mini-buffer. Well, with the following code in your
personal directory in prelude 😉 ),
M-x fortune-message will do just that. I’m considering submitting a patch, but there appears to be a bit of a procedure that I must review first.
|;; Be sure to set the following to your specific fortune files|
|(setq fortune-dir "~/.fortunes"|
|(defun fortune-message (&optional file)|
|"Display a fortune cookie to the mini-buffer.|
|If called with a prefix, it has the same behavior as `fortune'.|
|Optional FILE is a fortune file from which a cookie will be selected."|
|(interactive (list (if current-prefix-arg|
|(defun fortune-generate (&optional file)|
|"Generate a new fortune and return it as a string.|
|Without an optional FILE argument it will use the value of `fortune-file'."|
|(progn (fortune-in-buffer t file)|
Although, to get
fortune.el to work I had to create a new writable fortune file as it was not satisfied using the read-only fortunes included with my distribution. And now I have cookies on demand (om nom nom…)