Over the past few weeks I have been working on bringing a few new features to weltschmerz, my terminal emulator. One of them is the addition of a major VTE feature that I had overlooked when I first prototyped it: The support for OSC 8 hyperlinks.
The remaining two are smaller in nature, but hopefully just as useful: The context menu has learned a couple of new tricks, namely copying a selection as HTML, and the ability to open the current directory in the desktop environment’s default file manager.
Additionally, I have overhauled and improved the configuration management code to make future changes and additions easier. These improvements include a small bug fix, but are otherwise invisible to the end user.
Head on over to the project page to get the newest version right away, or read on to take a closer look at each new feature.
Hyperlink support
The motivation for this feature came when I read about
the new -fanalyzer
static analysis pass that will come with GCC 10.
The post mentions that in sufficiently capable terminals, new CWE
identifiers and the option names for warnings are clickable hyperlinks
pointing people to the right place in the documentation.
Since the post mentioned gnome-terminal as one such capable emulator, I assumed that VTE had to have been updated with hyperlink support and went to find out when that happened. It turned out that it had been added way back when in 2017, I just never paid much attention to it.
Since VTE already had full support, I decided to add this feature to weltschmerz as well. Now, if enabled, hyperlinks are clickable; they open up in the application that GLib thinks is best for the given URI. To make the user aware of what they will open, the terminal now renders a tooltip with the URI when hovering over a hyperlink:
Given the relative infancy of this functionality, and a couple of security concerns, this feature is disabled by default. If you want to try it out, it can be enabled in weltschmerz’s config file like so:
[misc]
allow-hyperlinks = true
Copy as HTML
Whilst looking through VTE’s Vala
documentation to find
out more about hyperlinks, I stumbled across the definition
for the Format enum which controls in what format the selection is
copied to the clipboard. TEXT
makes the clipboard contain the plain
text copy of the selection, and HTML
formats the selection as HTML,
with mostly complete style and colour information, like this:
diff --git a/NEWS b/NEWS index a9b1359..4e1c329 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ This file lists important changes to the weltschmerz terminal emulator. +Changes in version 1.2.1, released on January 17, 2020: + + --- MINOR BUGFIXES --- + * weltschmerz.1: The manual page now contains updated contact and author + information. + Changes in version 1.2.0, released on December 30, 2019: --- MINOR NEW FEATURES ---
Adding support for this was straightforward. Copy as HTML is now
available as a context menu entry whenever there is an active selection.
The above is an excerpt of the output of git-diff(1)
from one of the
release commits. Except for the font (which depends on your browser),
this is exactly how it looked in my terminal.
Open directory
For the longest time I primarily used ranger, a terminal file manager, to traverse directories and open files quickly. A few months back I decided to try out a few GUI-based ones and found that Thunar does the job very well. So well, in fact, that I rarely use ranger anymore these days. I find that for regular day-to-day browsing, I am much faster with the mouse and quick drag-and-drop actions are now essential to me.
I still spend most of my time in a terminal, however, and whilst it is very easy to open a terminal from within Thunar, it used to be not so easy to open an instance of Thunar (or whichever file manager you prefer) from within weltschmerz.
Now, with the new Open directory context menu entry (or by hitting
Ctrl+Shift+O
), weltschmerz opens the current directory in the desktop
manager’s default file manager. Note that VTE relies on OSC 7 to
determine which directory an application is in.
The shell I use, fish, emits the correct
escape sequence automatically
whenever it enters a new directory, but other shells will most likely
not do this by default. In that case, the menu entry will be greyed
out. However, for other shells, it should simply be sufficient to put the
proper escape sequence into PS1
or something comparable to
PROMPT_COMMAND
in bash. Note that it has to contain a URI (and not
a regular path).
Consider something like the following (though note that hostname
and path
should be URL-encoded):
printf '\e]7;file://%s%s\a' "$hostname" "$path"
Closing
That’s it for this release. I hope these new features will be useful (or at least interesting) to people. Until next time!