<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Konsole on KDE Blogs</title><link>https://blogs.kde.org/categories/konsole/</link><description>Recent content in Konsole on KDE Blogs</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 31 Mar 2026 18:04:10 +0300</lastBuildDate><atom:link href="https://blogs.kde.org/categories/konsole/index.xml" rel="self" type="application/rss+xml"/><item><title>Konsole Layout Automation (part 2)</title><link>https://blogs.kde.org/2025/04/02/konsole-layout-automation-part-2/</link><pubDate>Wed, 02 Apr 2025 00:00:00 +0000</pubDate><author>Tracey Clark</author><guid>https://blogs.kde.org/2025/04/02/konsole-layout-automation-part-2/</guid><description>&lt;p&gt;In &lt;a href="https://blogs.kde.org/2024/06/11/konsole-layout-automation-part-1/"&gt;Konsole Layout Automation (part 1)&lt;/a&gt;, I wrote about how to automate opening Konsole with different tabs that ran different commands. In this post, I'll talk about doing this for layouts.&lt;/p&gt;
&lt;h2 id="inspiration"&gt;Inspiration&lt;/h2&gt;
&lt;p&gt;In the past, I needed to open two connections to the same host over &lt;code&gt;ssh&lt;/code&gt; , and change to two different directories. I opened Konsole with a layout that had two panes. Then, Quick Commands allowed me to run a command in each pane to &lt;code&gt;ssh&lt;/code&gt; and change to the right directory. This post will outline how to achieve that and more!&lt;/p&gt;
&lt;h2 id="goal-launch-a-konsole-window-with-one-tab-that-has-multiple-panes-which-run-commands"&gt;Goal: Launch a Konsole window with one tab that has multiple panes which run commands&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note&lt;/strong&gt;
For more detailed instructions on using Konsole, please see the output of &lt;code&gt;konsole --help&lt;/code&gt; and take a look at the Command-line Options section of the &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/index.html"&gt;Konsole Handbook&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;A layout can save and load a set of panes. Unfortuately, it can't do anything else. We can, however, use profiles and the Quick Commands plugin to make the panes more useful.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; See the output of different commands in the same window. For instance, you could be running &lt;code&gt;htop&lt;/code&gt; in one pane and open your favorite editor in another.&lt;/p&gt;
&lt;p&gt;Here's an overview of the steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up a layout&lt;/li&gt;
&lt;li&gt;Use QuickCommands to run things in the panes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="set-up-a-layout"&gt;Set up a layout&lt;/h2&gt;
&lt;p&gt;Unfortunately, the &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/command-line-options.html"&gt;online documentation for Konsole command line options&lt;/a&gt; doesn't say much about how to create a layout, or the format of its JSON file. It only mentions the command line flag &lt;code&gt;--layout&lt;/code&gt;. &lt;em&gt;Also make a note of &lt;code&gt;-e&lt;/code&gt; which allows you to execute a command.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Fortunately, creating the layout is pretty easy. Note that a layout is limited to one tab. It will only save the window splits, nothing else. No profiles, directories, etc.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set up a tab in Konsole with the splits you want it to have&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;View -&amp;gt; Save Tab Layout&lt;/code&gt; to save it to a .json file. (I personally recommend keeping these in a specific directory so they're easy to find later, and for scripting. I use &lt;code&gt;~/konsole-layouts&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;You can then use &lt;code&gt;konsole --layout ~/layout-name.json&lt;/code&gt; to load konsole with a tab that has the splits you saved.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="use-quick-commands-to-do-useful-things-in-your-layout"&gt;Use Quick Commands to do useful things in your layout&lt;/h2&gt;
&lt;p&gt;As mentioned above, you can only save splits. you can't associate a profile, or run a command directly like you can with the tilix or kitty terminals. This has &lt;a href="https://bugs.kde.org/show_bug.cgi?id=455143"&gt;been requested&lt;/a&gt;. In the meantime, an easy thing you &lt;em&gt;can&lt;/em&gt; do is load a layout and then load a profile manually in each pane. This is where Quick Commands come in. These are under Plugins - Quick Commands. (If you don't see this, contact your distro / the place you installed Konsole from).&lt;/p&gt;
&lt;p&gt;You can use Quick Commands to run a command in each pane. You can also launch a profile (with different colors etc) that runs a command (&lt;a href="https://blogs.kde.org/2024/06/11/konsole-layout-automation-part-1/"&gt;part 1&lt;/a&gt; showed how these might be used). Note, however, that running &lt;code&gt;konsole&lt;/code&gt; itself from here will launch a new Konsole window.&lt;/p&gt;
&lt;p&gt;End each command with &lt;code&gt; || return&lt;/code&gt; so that you get to a prompt if the command fails.&lt;/p&gt;
&lt;p&gt;Examples&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;htop || return
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So, after you've launched Konsole with your layout as described above, you can do this:
Go to &lt;code&gt;Plugins -&amp;gt; Show Quick Commands&lt;/code&gt;
Add commands you'd like to run in this session.
Now, focus the pane and run a command.&lt;/p&gt;
&lt;p&gt;Using these steps, I can run &lt;code&gt;htop&lt;/code&gt; in one pane and &lt;code&gt;nvtop&lt;/code&gt; in the other.&lt;/p&gt;
&lt;p&gt;After you've gotten familiar with tabs and layouts, you can make a decently powerful Konsole session. Combine these with a shell function, and you can invoke that session very easily.&lt;/p&gt;
&lt;h2 id="this-is-still-too-manual"&gt;This is still too manual!&lt;/h2&gt;
&lt;p&gt;You're right. This post is about automating Konsole and having to click on things is not exactly that. You can use dbus commands in a script to load your tab layout and then run commands in each pane without using Quick Commands.&lt;/p&gt;
&lt;p&gt;As we saw in the &lt;a href="https://blogs.kde.org/2024/06/11/konsole-layout-automation-part-1/"&gt;last post&lt;/a&gt;, you can use profiles to customize color schemes and launch commands. We can call those from a script in a layout. The demo scripts used below use &lt;code&gt;dbus&lt;/code&gt;, take a look at &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/scripting.html"&gt;the docs on scripting Konsole&lt;/a&gt; for details.&lt;/p&gt;
&lt;p&gt;I'm using the layout file &lt;code&gt;~/konsole_layouts/monitoring.json&lt;/code&gt; for this example.
This layout file represents two panes with one &lt;em&gt;vertical&lt;/em&gt; split (horizontal orientation describes the panes being horizontally placed):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;Orientation&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Horizontal&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;Widgets&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;SessionRestoreId&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;SessionRestoreId&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here's an example of a simple script using that layout, which will launch &lt;code&gt;fastfetch&lt;/code&gt; in one pane and &lt;code&gt;btm&lt;/code&gt; in the other:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!/usr/bin/env bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Define the commands to run&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;cmd1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;fastfetch&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;cmd2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;btm&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Opens a konsole tab with a saved layout&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Change the path to point to the layout file on your system&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# KPID is used for renaming tabs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --hold --layout &lt;span class="nv"&gt;$HOME&lt;/span&gt;/konsole_layouts/monitoring.json &lt;span class="p"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;KPID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Short sleep to let the tab creation complete&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sleep 0.5
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Runs commands in Konsole panes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;qdbus &lt;span class="p"&gt;|&lt;/span&gt; grep -B1 konsole &lt;span class="p"&gt;|&lt;/span&gt; grep -v -- -- &lt;span class="p"&gt;|&lt;/span&gt; sort -t&lt;span class="s2"&gt;&amp;#34;.&amp;#34;&lt;/span&gt; -k2 -n &lt;span class="p"&gt;|&lt;/span&gt; tail -n 1&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qdbus &lt;span class="nv"&gt;$service&lt;/span&gt; /Sessions/1 org.kde.konsole.Session.runCommand &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;cmd1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qdbus &lt;span class="nv"&gt;$service&lt;/span&gt; /Sessions/2 org.kde.konsole.Session.runCommand &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;cmd2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Renames the tabs - optional&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qdbus org.kde.konsole-&lt;span class="nv"&gt;$KPID&lt;/span&gt; /Sessions/1 setTitle &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;System Info&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qdbus org.kde.konsole-&lt;span class="nv"&gt;$KPID&lt;/span&gt; /Sessions/2 setTitle &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;System Monitor&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What it does:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Loads a layout with 2 panes, horizontally arranged&lt;/li&gt;
&lt;li&gt;Runs &lt;code&gt;clear&lt;/code&gt; and then &lt;code&gt;fastfetch&lt;/code&gt; in the left pane; runs &lt;code&gt;btm&lt;/code&gt; in the right pane&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="wrap-up"&gt;Wrap-up&lt;/h2&gt;
&lt;p&gt;That's how you can accomplish opening a number of panes in &lt;code&gt;konsole&lt;/code&gt; which run different commands. Using this kind of shortcut at the start of every work / programming session saved a little time every day which adds up over time. The marketing peeps would call it &amp;quot;maximizing efficiencies&amp;quot; or something. I hope some folks find this useful, and come up with many creative ways of making &lt;code&gt;konsole&lt;/code&gt; work harder for them.&lt;/p&gt;
&lt;h2 id="known-issues-and-tips"&gt;Known issues and tips&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Running &lt;code&gt;konsole&lt;/code&gt; from a Quick Command will open a new window, even if you want to just open a new tab.&lt;/li&gt;
&lt;li&gt;You may see this warning when using runCommand in your scripts. You can ignore it. I wasn't able to find documentation on what the concern is, exactly.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;The D-Bus methods sendText/runCommand were just used. There are security concerns about allowing these methods to be public. If desired, these methods can be changed to internal use only by re-compiling Konsole. This warning will only show once for this Konsole instance.
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="credits-to-inspirational-sources"&gt;Credits to inspirational sources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Thanks to the &lt;a href="https://github.com/Gsarod/Cool-Konsole-setup"&gt;Cool-Konsole-setup&lt;/a&gt; repo, where I found an example script for using commands in a layout via &lt;code&gt;qdbus&lt;/code&gt;. Note: The scripts in that repo did not work as-is.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://askubuntu.com/a/1491500"&gt;This answer on Ask Ubuntu&lt;/a&gt; for improvements on the example scripts.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Konsole Layout Automation (part 1)</title><link>https://blogs.kde.org/2024/06/11/konsole-layout-automation-part-1/</link><pubDate>Tue, 11 Jun 2024 00:00:00 +0000</pubDate><author>Tracey Clark</author><guid>https://blogs.kde.org/2024/06/11/konsole-layout-automation-part-1/</guid><description>&lt;p&gt;Do you find yourself opening up the same tabs in your terminal and running the same commands every day? Have you wanted to make this easier, say, by clicking a desktop icon or running a short command?&lt;/p&gt;
&lt;p&gt;Recently, I saw a question along these lines in the &lt;a href="https://go.kde.org/matrix/#/%23kde:kde.org"&gt;KDE support room on Matrix&lt;/a&gt;. Someone wanted to have &lt;a href="https://konsole.kde.org/"&gt;Konsole&lt;/a&gt; automatically open some tabs and run specific commands when it's started. Since I've done this kind of thing, for personal and professional environments, I thought I'd share. You too can avoid doing the same manual terminal setup day after day, and just get to what you're working on.&lt;/p&gt;
&lt;p&gt;Here in Part 1, I'll outline how to open tabs with different profiles and run commands in them. Next week, in Part 2, I'll share how to set up layouts (a.k.a. split panes) and run commands in those. You can combine these techniques to make your setup truly flexible. Using aliases, functions and scripts, you can bring up a complex layout with one command or button click.&lt;/p&gt;
&lt;h2 id="inspiration"&gt;Inspiration&lt;/h2&gt;
&lt;p&gt;I have a motto: If I have to do the exact same thing more than twice (on a computer), I should probably script / automate it. It's an up front time investment that saves me a lot of manual tedium later.&lt;/p&gt;
&lt;p&gt;My inspiration for scripting terminal layouts came from iTerm2's customization abilities. After a few years of using it on a work-provided MacBook Pro, I was spoiled. It's truly nice how easy it is to create profiles and save splits in the GUI. You can then tweak their configurations using any text editor. When I searched for how to do this with Linux terminals, I found quite a few people were also looking for an &amp;quot;iTerm2 equivalent for Linux&amp;quot;.&lt;/p&gt;
&lt;h2 id="goal-launch-a-konsole-window-with-tabs-which-run-commands"&gt;Goal: Launch a Konsole window with tabs which run commands&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note&lt;/strong&gt;
For more detailed instructions on using Konsole, please see the output of &lt;code&gt;konsole --help&lt;/code&gt; and take a look at the &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/index.html"&gt;Konsole Handbook&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;We'll start with that request from Matrix: having Konsole create tabs and run commands in them when it starts. Here are the steps I used to accomplish this. Feel free to use this as inspiration and adapt for your own needs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; Quickly set up a working environment that I use daily to save time every day. There will be a couple of tabs connected to different remote hosts, one that changes to a notes directory, and one running a system monitor.&lt;/p&gt;
&lt;p&gt;Here's an overview of the steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a Konsole profile which will run a command and optionally use another color theme&lt;/li&gt;
&lt;li&gt;Create a tab layout file to launch Konsole with which will open a tab with that profile&lt;/li&gt;
&lt;li&gt;Create a profile with a different command for an additional tab, and then identify commands for a couple of the other tabs&lt;/li&gt;
&lt;li&gt;Update the tab layout file to launch Konsole with all the desired tabs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now let's get into the details.&lt;/p&gt;
&lt;h2 id="create-the-first-konsole-profile"&gt;Create the first Konsole profile&lt;/h2&gt;
&lt;p&gt;Making custom profiles for different hosts are where my adventures in customizing Konsole began.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; I would like to automatically connect to my hosted VPS in a tab with a specific color theme.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reasoning:&lt;/strong&gt; Running commands using a theme is quicker and easier than typing by hand (especially as they get more complex). With a custom color scheme, I can see at a glance which tab has my server session vs. any other system. This helps me avoid typing commands for my server into another system and vice-versa.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note&lt;/strong&gt;
Profiles are stored as plain text files in &lt;code&gt;/.local/share/konsole/&lt;/code&gt;.
Profile names are cAsE senSiTive.
Since profile files are plain text, you can create, edit, and delete them with scripts. That is beyond the scope of this post.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The first step is to set up a custom profile with a custom color theme, a custom tab title format, and a command.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I'm using &amp;quot;&lt;a href="https://eternalterminal.dev/"&gt;eternal terminal&lt;/a&gt;&amp;quot; (&lt;code&gt;et&lt;/code&gt;) for its ability to reconnect, rather than &lt;code&gt;ssh&lt;/code&gt; to connect to the VPS. I also have an entry for the host in &lt;code&gt;.ssh/config&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In Settings -&amp;gt; Manage Profiles - New I created a profile named VPS. The following are the options I changed. Others were left as-is (&amp;quot;hostname&amp;quot; is a stand-in for the actual VPS hostname):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Name: VPS
Command: et VPS
Tab title format: %n hostname
Tab Color: I chose a color
Appearance - Color scheme &amp;amp; font: I chose a different color scheme
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that I have a custom profile, I can use it with a new tab in Konsole. When I go to File -&amp;gt; New Tab and click &amp;quot;VPS&amp;quot;, the tab will open with the new profile, and the command will run to connect to the server.&lt;/p&gt;
&lt;p&gt;You can use Konsole's &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/command-line-options.html"&gt;command line options&lt;/a&gt; in the following way to have it launch with a tab using a profile.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab --profile VPS
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This command can be used with an alias, function, script, Windows batch file, desktop shortcut or whatever you prefer.&lt;/p&gt;
&lt;p&gt;There's another way to launch Konsole which is better for opening multiple tabs. It uses a &amp;quot;tabs configuration file&amp;quot;.&lt;/p&gt;
&lt;h3 id="create-a-tabs-configuration-file"&gt;Create a tabs configuration file&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note&lt;/strong&gt;
I have found this to be unreliable if any tab uses &lt;code&gt;ssh&lt;/code&gt; or &lt;code&gt;et&lt;/code&gt;
There's an &lt;a href="https://bugs.kde.org/show_bug.cgi?id=488396"&gt;open bug report for this&lt;/a&gt;. Until this is resolved, you may have better luck with a shell script that opens multiple tabs, I'll add information below.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now I'll create a tabs configuration file with the VPS profile in it.&lt;/p&gt;
&lt;p&gt;Each line in this file describes a tab for Konsole to open. The format is detailed in the &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/command-line-options.html"&gt;command line options documentation&lt;/a&gt;. I keep these in &lt;code&gt;~/konsole_layouts/&lt;/code&gt;, keep yours in whatever directory works for you. I'll save this file as &amp;quot;vps-tabs&amp;quot;.&lt;/p&gt;
&lt;p&gt;Each line must have at least a profile or a command field. It can have both, and there are &lt;a href="https://docs.kde.org/stable5/en/konsole/konsole/command-line-options.html"&gt;other options as well&lt;/a&gt;.&lt;br&gt;
&lt;em&gt;Do not specify a command on a line for a tab if you also use a profile which itself has a command. This may lead to unexpected behavior.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you only need to run a command in a tab, you can just use the command field. You combine a command with a profile (that has no command) if you want to customize the tab further.&lt;/p&gt;
&lt;p&gt;This is what will go in the file for now for my first tab:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;title: VPS ;; profile: VPS
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The command below will start Konsole using this file. (Change file path to point to the file on your system). Opening Konsole in this way can also be done with an alias, script etc.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --hold --tabs-from-file ~/konsole_layouts/vps-tabs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice that I'm using &lt;code&gt;--hold&lt;/code&gt; which tells Konsole to keep tabs open even after their command has exited. This will help debugging any problems that might arise (unless the window crashes entirely or fails to load). Once things are set up and running smoothly, you don't need to use &lt;code&gt;--hold&lt;/code&gt;, if you prefer.&lt;/p&gt;
&lt;h2 id="create-additional-profiles"&gt;Create additional profiles&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; At the start of the day, I want to automatically open tabs which connect to both servers I need to work with. I want an additional tab open to my notes directory and another one running a system monitor.&lt;/p&gt;
&lt;p&gt;Time to add an additional profile to Konsole:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Server2 - this will use &lt;code&gt;ssh&lt;/code&gt; to connect to a second server and use a profile for a different color theme&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I won't create profiles for the system monitor tab or the Notes tab. I'll run those commands directly from the tab configuration file.&lt;/p&gt;
&lt;h2 id="update-the-tabs-file-with-additional-tab-definitions"&gt;Update the tabs file with additional tab definitions&lt;/h2&gt;
&lt;p&gt;At this point, I'll add lines to the tabs configuration file I created.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A tab for the Server2 profile.&lt;/li&gt;
&lt;li&gt;A tab which changes to a notes directory, and uses the Sand profile with colors I prefer for them.&lt;/li&gt;
&lt;li&gt;A tab for the system monitor which runs the &lt;code&gt;btm&lt;/code&gt; command and uses another profile with yet another color scheme.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The file now looks like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;title: VPS ;; profile: VPS
title: SysAdminNotes ;; workdir: ~/Nextcloud/Notes/SysAdmin ;; profile: Sand
title: Server2 ;; profile: Server2
title: NavyBlue ;; command: btm ;; profile: NavyBlue
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And now, when I run &lt;code&gt;konsole --hold --tabs-from-file ~/konsole_layouts/vps-tabs&lt;/code&gt;, Konsole launches with all the tabs I need.&lt;/p&gt;
&lt;h2 id="bonus-run-commands-after-connecting-to-a-remote-host"&gt;Bonus: Run commands after connecting to a remote host&lt;/h2&gt;
&lt;p&gt;It's possible with both &lt;code&gt;ssh&lt;/code&gt; and &lt;code&gt;et&lt;/code&gt; to run commands on a remote host after connection. For instance, I could update the command in my VPS profile like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Name: VPS
Command: et VPS -c 'sudo apt update &amp;amp;&amp;amp; apt list --upgradable; exec /bin/zsh'
Tab title format: %n hostname
Tab Color: I chose a color
Appearance - Color scheme &amp;amp; font: I chose a different color scheme
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The command not only connects to my VPS, it also displays a list of any available updates, and stays connected to the host. Note the &lt;code&gt;exec /bin/zsh&lt;/code&gt; at the end. This will keep an interactive terminal open after other commands are run.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;ssh&lt;/code&gt;, to run a command on a remote host while staying connected, the command is slightly different:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh -t VPS &lt;span class="s1"&gt;&amp;#39;sudo apt update &amp;amp;&amp;amp; apt list --upgradable; zsh&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="but-what-if-i-need-to-connect-to-a-jumphost-before-the-remote-host-and-i-still-want-to-run-a-command-after-i-connect"&gt;But what if I need to connect to a jumphost before the remote host and I still want to run a command after I connect?&lt;/h3&gt;
&lt;p&gt;This can be done with either SSH or Eternal Terminal. For SSH, the process is relatively easy, and plenty of sites online provide instructions. Eternal Terminal, on the other hand, is a bit more tricky.&lt;/p&gt;
&lt;p&gt;It took some research and experimentation to get this working with Eternal Terminal, so here it is (&amp;quot;jumphost&amp;quot; is a placeholder for the actual hostname of the jumphost).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;Command&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;et jumphost -c &lt;span class="s2"&gt;&amp;#34;ssh -t remotehost &amp;#39;cd /some/directory &amp;amp;&amp;amp; . ../some_script &amp;amp;&amp;amp; cd ../another-directory; exec /bin/zsh&amp;#39;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="alternative-to-using-a-tabs-file-a-shell-script-or-function"&gt;Alternative to using a tabs file: a shell script or function&lt;/h2&gt;
&lt;p&gt;If you have difficulties with using a tabs configuration file, you can use a shell script (or function) that takes advantage of the command line options Konsole has. For instance, using the &lt;code&gt;-e&lt;/code&gt; flag we can have tabs run commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!/usr/bin/env bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;&lt;/span&gt;konsole --new-tab -e &lt;span class="nb"&gt;echo&lt;/span&gt; This is tab &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab -e &lt;span class="nb"&gt;echo&lt;/span&gt; This is tab &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab -e &lt;span class="nb"&gt;echo&lt;/span&gt; This is tab &lt;span class="m"&gt;3&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab -e &lt;span class="nb"&gt;echo&lt;/span&gt; This is tab &lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can combine commands with profiles as well:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!/usr/bin/env bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;&lt;/span&gt;konsole --new-tab --profile VPS &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab --profile Sand --workdir: ~/Nextcloud/Notes/SysAdmin &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab --profile Server2 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;konsole --new-tab --profile NavyBlue -e btm &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Explore the Konsole docs and experiment!&lt;/p&gt;
&lt;h2 id="known-issues"&gt;Known issues&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Launching Konsole with &lt;code&gt;--tabs-from-file&lt;/code&gt; will open an extra tab in addition to the ones from the configuration file. This has &lt;a href="https://bugs.kde.org/show_bug.cgi?id=487896"&gt;an open bug report&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Sometimes, with &lt;code&gt;--tabs-from-file&lt;/code&gt;, the new Konsole window immediately disappears. This &lt;em&gt;may&lt;/em&gt; be related to ssh/et being in a command. I filed &lt;a href="https://bugs.kde.org/show_bug.cgi?id=488396"&gt;a bug report for that&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;If using a tabs configuration file, or a script: only use Eternal Terminal with one tab. Trying to use it with more than one tab will result in &lt;code&gt;et&lt;/code&gt; core dumping in one of them.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>