This is a small Tutorial how to convert Konsole to never, I mean never, open a new window again.

I mean, we moved away from Windows for a reason, right?

Also, I will show you how to use a different shell and add custom right-click actions for various useful things.

screenshot

No new windows

Go to Konsoles Settings, the second checkbox is “open all konsole windows in a single process”. Check this, as it is needed.

Now to edit the system desktop entry, never do this in place, copy it to your user directory, entries here always overwrite system ones. (This can be used to hide apps too, use touch ~/.local/share/applications/name.desktop)

cp /usr/share/applications/konsole.desktop ~/.local/share/applications/

Now edit this file with your editor.

Replace Exec=konsole with Exec=konsole --new-tab.

Profile: Different Shell

Bash is the default and I highly advise against using chsh if you want to use fish, zsh or others.

Instead, create a new Konsole profile, set its default command to for example /usr/bin/fish and set it as default profile!

Profile: Distrobox

If you use Distrobox, you may want a profile that launches it directly. The advantage is that you can color it differently and much more.

In the settings create a new profile and set the startup command to distrobox enter Boxname.

Mine is for Fedora, while my main system is Fedora Atomic KDE.

Custom right-click actions

You can remove unneeded translations from the desktop entry to make it easier to work with.

In the Actions= line you define what you want. Below the main entry you put the actions with name, icon and command.

Here I have examples for launching the Distrobox Profile, opening a root shell and opening a remote ssh session.

The complete desktop entry (click me to expand)
[Desktop Entry]
Type=Application
TryExec=konsole
Exec=konsole --new-tab
Icon=utilities-terminal
Categories=System;TerminalEmulator;
Actions=FedoraBox;root;ssh;
X-DocPath=konsole/index.html
X-DBUS-StartupType=Unique
X-KDE-AuthorizeAction=shell_access
X-KDE-Shortcuts=Ctrl+Alt+T
StartupWMClass=konsole
Keywords=terminal;console;script;run;execute;command;command-line;commandline;cli;bash;sh;shell;zsh;cmd;command prompt
Name=Konsole
GenericName=Terminal
Comment="$GenericName"

[Desktop Action FedoraBox]
Name=Distrobox
Icon=fedora-logo-icon
Exec=konsole --new-tab --profile FedoraBox # this launches "distrobox enter FedoraBox"

[Desktop Action root]
Name=root Terminal
Icon=folder-root-symbolic
Exec=konsole --new-tab -e pkexec $SHELL #or define a shell like fish

[Desktop Action ssh]
Name=ssh to X
Icon=folder-remote-symbolic
Exec=konsole --new-tab -e ssh user@IP:PORT -i /path/to/key

Note that I removed the actions for “new tab” and “new window”. For some reason Plasma shows the “open new window” always, and due to the replacement this opens a new tab instead.

Ctrl+Alt+t, opening from Dolphin and more will also open a new tab.

Btw, if somebody can help me figure out how to focus the Konsole window when opening a new tab, that would be nice. This is currently missing

  • Lunch
    link
    19 months ago

    Thanks for sharing!