Skip to content

Instantly share code, notes, and snippets.

@michaelbutler
Last active January 31, 2025 11:19
Show Gist options
  • Save michaelbutler/723156c84a3c6eaa53f898f5b9021f9b to your computer and use it in GitHub Desktop.
Save michaelbutler/723156c84a3c6eaa53f898f5b9021f9b to your computer and use it in GitHub Desktop.
Auto open and split multiple Konsole tabs in KDE using a simple script

How to script and configure Konsole Splits and Tabs Automatically

Screenshot_20220617_144315

Find yourself repeatedly opening new tabs and splitting consoles every time you restart your machine? I made a shell script (and a json file) to set up Konsole exactly how I want it just by running a single command (also linked with a Desktop shortcut).

How To

First create a file called tab.layout.json and store it in $HOME.

{
    "Orientation": "Vertical",
    "Widgets": [
        {
            "SessionRestoreId": 1
        },
        {
            "SessionRestoreId": 0
        }
    ]
}

Then create another text file (shell script) konsole-splits.sh and put it where you want. I put it in ~/bin which I have configured as part of my $PATH for executing. Use chmod +x konsole-splits.sh to make it executable.

#!/bin/bash

# konsole-splits.sh

konsole --layout tab.layout.json --new-tab &
konsole --layout tab.layout.json --new-tab &
konsole --layout tab.layout.json --new-tab &
konsole --layout tab.layout.json --new-tab &

Now whenever you run konsole-splits.sh, it will open Konsole with 4 tabs, each tab with a horizontal split (one terminal on top of another one). You can customize the script and the json file to your liking. If Konsole is already running, it will add 4 new tabs each time.

Screenshot_20220617_145240

@enrichilversum
Copy link

There is an option for creating a tabs layout which accepts commands. If you don't need splits, this would be the proper way of working. The argument is --tabs-from-list
What would be ideal, is to be able to somehow make both work together. I tried adding the options that I get with --list-profile-properties to the JSON file, but they are ignored. And opening a tabs file and a layout opens the layout as one tab (or a series of them) and the tabs in the tabs file as extra, unsplit, tabs...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment