hamwaves.com
;

Multiplexing the XFCE Terminal Emulator

Serge Y. Stroobandt

Copyright 2015–2017, licensed under Creative Commons BY-NC-SA

  1. Home
  2. IT
  3. Command Line
  4. XFCE Terminal Multiplexing

This page is still under construction. All scripts do work, however.

TODO: Write up remaining article text.

Introduction

Lately, I have become a frequent user of the xfce4-terminal terminal emulator on Xubuntu LTS. I use it mainly to launch hg Mercurial push & pull distributed version control commands. My text based journal and remind calendar also automatically launch terminal emulators to keep a watchful eye on their respective hg push & pulls whilst synchronising with my server.

However, with this increased terminal use, the overlapping pile of identically labelled «Terminal» buttons on my open windows bar started to annoy me. How am I supposed to retrieve the right terminal when they are all named the same?

I tried using more often ShiftCtrlT to open tabs in already existing terminal windows. That solution was still not good enough, though.

Consequently, I had a swift look at the established terminal multiplexers GNU screen, tmux and byobu. These applications sure ought to have their merit, but in my experience, the terminal multiplexers simply get too much in my way.

Luckily, GNU/Linux applications very much resemble raw minerals; some love and a good polishing job will turn them into really shiny wannahave gems. XFCE’s default terminal emulator xfce4-terminal is no different in that respect. It suffices to issue a quick man xfce4-terminal to list the vast array of little used command line arguments that await discovering. This very same information is also available from the online XFCE documentation.

Screenshot

With this information, a «multiplexer» script was written; i.e. an augmented script version of the original xfce4-terminal executable with automatic multiplexing added. Below screenshot shows what the xfce4-terminal multiplexer looks like. Subsequent calls to xfce4-terminal are opened in new and automatically labelled tabs in one and the same window.

The multiplexed xfce4-terminal; subsequent calls to the terminal are opened in new and automatically labelled tabs in this very same window.

Setting up ~/bin

Still interested? Fine! To proceed, we need to make sure that versions of executables in your personal ~/bin directory are found first by the system. They need to take preference upon execution over the packaged versions bearing the same name. If you have not done so yet, create your very own ~/bin directory. Having such a personal ~/bin directory on your system is quite handy, also for other projects. If done properly, it will by no means upset your system. So, feel safe to go ahead.

$ cd
$ mkdir bin

If you are using a relatively modern GNU/Linux distribution, you stand a high chance it will feature a ~/.profile file which already contains a PATH variable putting $HOME/bin first. If this is the case, simply disregard the remainder of this section.

If this is not the case, add the following line as the last line to your ~/.bashrc configuration file:

PATH="$HOME/bin:$PATH"; export PATH

Required packages

xfce4-terminal, wmctrl, egrep, pidof Beware, pidof is not available in all GNU/Linux distributions! You may try your luck with pgrep, even though it is not a real drop-in replacement.

$ touch ~/bin/xfce4-terminal
$ chmod +x ~/bin/xfce4-terminal

The xfce4-terminal multiplexer script

Download: xfce4-terminal
License: GNU GPL version 3

Configuring the desktop

What rests to be done

Preferred terminal emulator

For new terminal tabs appropriate titles

In Settings → Preferred Applications → Utilities → Terminal Emulator, put:

xfce4-terminal --command="%s" --title="%s"

This change takes immediately effect; logging in and out of the session is not required.

Terminal launcher

In a Terminal Emulator launcher, just put: (Default is: exo-open --launch TerminalEmulator.)

xfce4-terminal

SpaceFM

In Xubuntu LTS, I prefer SpaceFM as the default file manager, over Thunar. At the SpaceFM menu bar, select View → Preferences → Advanced → Terminal, put:

xfce4-terminal --title="%D"

vimrc

As a bonus, In .vimrc, put:

command! Terminal :call system("xfce4-terminal --working-directory='".expand("%:p:h")."' &")
noremap  <silent> <F4> :Terminal<CR>
vnoremap <silent> <F4> <ESC>:Terminal<CR>
inoremap <silent> <F4> <ESC>:Terminal<CR>

Conclusion

hope that XFCE and Xubuntu developers will pick up this idea.

5
Creative Commons Licence
This work is licensed under a Creative Commons Attribution‑NonCommercial‑ShareAlike 4.0 International License.
Other licensing available on request.
GNU GPL v3
Unless otherwise stated, all originally authored software on this site is licensed under the terms of GNU GPL version 3.
cookie
This static web site has no backend database.
Hence, no personal data is collected and GDPR compliance is met.
Moreover, this domain does not set any first party cookies.

All Google ads shown on this web site are, irrespective of your location,
restricted in data processing to meet compliance with the CCPA and GDPR.
However, Google AdSense may set third party cookies for traffic analysis and
use JavaScript to obtain a unique set of browser data.
Your browser can be configured to block third party cookies.
Furthermore, installing an ad blocker like EFF's Privacy Badger
will block the JavaScript of ads.
Google's ad policies can be found here.
This page employs a Python Bottle server‑side script.
This page includes an open-source client-side script, written in Python and
transcoded by Brython to make it run as secure JavaScript in the browser.
Static XHTML generated from Markdown by Pandoc and
the GNU/Linux make, sed and gpp commands.
LaTeXmath markup rendered with MathJax.
BibTeX references are best read with JabRef.
Unattended CSS typesetting with Prince.
This work is published at https://hamwaves.com/xfce.terminal/en/.
profile for Serge Stroobandt on Stack Exchange, a network of free, community-driven Q&A sites
GnuPG
Use my OpenPGP public key to encrypt messages for:

echo c2VyZ2VAc3Ryb29iYW5kdC5jb20K |base64 -d
Last update: Wednesday, March 24, 2021.