Understanding (and customizing) Tilix

Tilix does things differently than most terminal emulators – for better and for worse.

If you’ve ever been bewildered by Tilix ( Terminix) logic and/or terminology, here’s a quick stab at clarification.

Tilix is an application that (mainly) runs in a single window. Inside that window, you can have multiple sessions. In those sessions you can have one or more terminals. Starting a new session also always starts up a single new terminal within it. Kill the last terminal in a session and the session dies, too. A profile is set globally but can be changed on a per-terminal basis.

Applications like Gnome Terminal have made the idea of a single window and a “terminal emulator” synonymous. So much so, I think, that even though the Tilix developers are probably right that each of their “terminals” is a single terminal emulator, it causes a lot of confusion. So to say it as clearly as I can: When you set “terminal” options in Tilix, you’re not configuring the application as a whole but a little subsection with a single prompt.

I have been unable to find any official guidance about how sessions and terminals are conceived of in the Tilix approach. So here is how I see it. Tilix is a notebook with squared paper or graph paper. The book is the application window. Each page is a session. Within each page I can have a single terminal – or as many as there are squares on the page, like dividing the graph paper by drawing boxes and lines. I think the implication for using Tilix is that I should/could cluster together all the terminals I need to view at the same time – e.g. nethogs and a firewall configurator – in a single session. That way I have all the information I need in front of me at the same time. Personally, that’s not my preference. I have never understood the desire for the Tetris approach to terminal emulator layout. But I think that’s the idea.

If you’re now thinking, “yes, yes, but where are the tabs?”, I’m right there with you. However, Tilix was not originally conceived with tabs as used in web browsers and since adopted in many other applications. Sessions were stored as small thumbnails in a drawer/sidebar hidden off to the left side. This also rhymes quite nicely with the notebook metaphor, since that’s also where PDF viewers put the document page overview: Look at the page overview in the sidebar, find the page you want, turn to that page. In version 1.7 users were given the option to have sessions displayed as tabs on top (or bottom, or to the sides) in stead of the sidebar. Fortunately, when that option is triggered, sessions and tabs are synonymous as far as I can tell. I will get into more detail below.

To be honest, the main point of this post is really just to spell this approach out, as it runs counter to the terminology used with most others terminal emulators. This means that whenever I come back to it, I feel like I have to learn it all over again. However, since I’m at it, I might as well share a few tips about configuring it.

Tilix allows you to avoid terminal littering

Since I’m not a fan of dividing the screen into many small terminal emulators, it might be a good idea to start with explaining why I use Tilix at all. Using the same command I can start an instance and reconnect with and focus it again. Running tilix with the –focus-window parameter simply brings me back to the application window I’ve already got running – or start one if none exists. In addition I’m able to start and focus new sessions and terminals within that same window from outside of Tilix, e.g. using the desktop environments custom keyboard shortcuts settings.

That way I can avoid having terminal emulator windows littered over multiple workspaces and going hunting for that one where I typed in that command I now need to revisit. Or the one with the SSH connection. Or etc.

No fat titlebars

Starting out simple, I’m not convinced that CSD makes title bars useful. So I’d rather do away with them alltogether. Tilix makes it easy with a single setting: Settings | Appearance | Window style. Set it to Borderless and restart.

Tabs > session sidebar

As mentioned above, Tilix developers grudgingly allows me to represent a session as a tab. In “normal” mode hitting F12 will give me a sidebar view of all sessions in the current window. Going to Settings | Appearance, ticking off Use tabs instead of sidebar (Application restart required) and closing down and starting Tilix up again and now each session (Ctrl-Shift-T for a new session) is a tab. This also means that all “session” related settings now apply to tabs. The overview usually provided by F12 is, however, disabled.

Single window

As mentioned above, the having a single terminal emulator window is a big draw.

The starting off point here is the setting in Settings | Global called On new instance which can be set to Focus window. However, this by itself will not be enough. Picking Tilix from a launcher, a Run application command utility or another terminal emulator – i.e. anything outside of Tilix itself – will still give me a new window.

In order for outside launchers to respect the “single window policy”, I need to either 1) run the command with the --focus-window parameter or 2) use an --action parameter that works on an existing window or session. For more on actions, see below. Basically, if all I care about is single window, I just need to add --focus-window to all keyboard shortcuts, .desktop icons etc. that I use.

The following line will open a new maximised terminal if there are not existing Tilix windows open – or focus the existing one if there is.

tilix --focus-window --maximize --title LOCALHOST

Note: If I start multiple windows intentionally or unintentionally, I will now have two session drawers that are kept separate. Using actions outside of Tilix will affect the last window to be active. Yet another reason to stick with one.

Tab titles

One thing I really like about XFCE4 terminal is how easy it is to set to set tab titles. Tab titles are useful to me because to me one host equals one tab/session. If I’m ever ind doubt of what host I’m on, I have the tab title as a quick aide mémoire.

Tilix makes this a little bit tricky because well, in Tilix session names – displayed as tab titles in tab mode – cannot be set directly from parameters. Terminals titles and window titles can. A window title is of little use if I have three sessions going on three different hosts. And while you can display terminal titles, they’re somewhat more discreet and less obvious than tab titles. Also a waste of vertical space since I never use more than one terminal per session.

The trick is using that very fact: that there is only ever one terminal in a session/tab. Setting Default session name (in Settings | Appearance) to ${activeTerminalTitle} and opening each new terminal in a new session with the --title flag (which refers to terminal title, not session or application title) will yield the desired result.

I will spell out the needed command line in the “Actions” section below because it depends on one more puzzle piece.

Start a new session with global shortcuts

Actions are command line parameters that work on either an existing window, e.g. to start a new session/tab in that window, or an existing, specific session within a window, e.g. to start a new terminal in it.

The following line focuses an existing window and starts up a new session in it. A new session automatically starts a single terminal within it, that is titled HOST5. Also within that terminal is run the ssh command that connects to host5.local. Since there are no other terminals in that session the setting above means that the session (read: tab) is titled HOST5, as well.

tilix --focus-window --action=app-new-session --title HOST5 -e ssh host5.local

Profile switching

I have only really included profiles to signal where they stand in the order of Tilix terminology. Profiles set all the same things that they do in Gnome Terminal, i.e. mainly appearance settings, like colors, fonts, and scrollbars. If I don’t tinker with them, the default profile will be applied to all my windows, sessions and terminals.

The one thing I do find interesting about Tilix profiles is the ability to automatically switch a terminal (and only that terminal) to a different profile based on either username, hostname or directory – or a combination of the three. That way I can have different colors alert me to the fact that I’m root or on a different host etc.

Nevertheless, I’m not sold on that feature for the simple reason that tmux does that job in a simpler more elegant way. Which leads me to…

A word on session management

The main reason I don’t care much for using Tilix with a one-session-many-terminals approachs is tmux. If I want many terminals in a sessions I will use tmux.

On the surface this may seem daft: Why complicate things with two tools when one can do the job? And the answer is that Tilix cannot do everything. The main thing it cannot do is keep a session running on a remote server. For that there is not substitute for SSHing into the server and resuming work in a detached tmux/GNU screen session.

Since I’ve had to learn how tmux does that on a remote server, I think it makes sense to use the same on my local desktop rather than adopt a totally different approach there.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.