I guess you could set it to run in a single process (settings>general) and then change the executable for konsole to konsole --new-tab and make sure the tab bar is always visible.
Futhermore, you can also start konsole with a couple of predefined tabs.
You’d need to create such a file in ~/.konsole ( if needed, create the folder) and it should look something like, for example:
workdir: /home/john;; title: Htop;; command:htop
workdir: /home/john;; title: Ranger;; command:ranger
workdir: /home/john;; title: Cava;; command:cava
You start it with “konsole --tabs-from-file /path/to/the/file”. It’ll always have a default tab, regardless how many predefined tabs you create in that file)
In that same folder you can also create a konsole.css in case you should like some fancy like highlighting the current tab and what not. You can enable that css in konsole ( settings>tabbar/splitters).
Something like ( starting konsole with a bunch of preloads and css):
I tried to hack together a service menu in combination with a script that lets you choose the window you want to open the new tab in using qdbus (requires kdialog).
Only thing I couldn’t figure out was how to focus/raise the window where the tab is created.
Save in ~/.local/share/kio/servicemenus/openInKonsoleTab.desktop
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openKonsoleHere;openKonsoleTabHere;
X-KDE-AuthorizeAction=shell_access
X-KDE-Priority=TopLevel
[Desktop Action openKonsoleTabHere]
TryExec=konsole
Exec=konsole-new-tab Default %f
Icon=utilities-terminal
Name=Open Konsole Tab Here
Comment=Opens a new Konsole tab at the current directory
[Desktop Action openKonsoleHere]
TryExec=konsole
Exec=konsole --workdir %f
Icon=utilities-terminal
Name=Open Konsole Here
Comment=Opens a Konsole window at the current directory
Save in ~/.local/bin/konsole-new-tab
#!/usr/bin/env bash
# Default to "Default" profile and home dir (/home/USER/)
PROFILE="${1:Default}"
DIRECTORY="${2:-HOME}"
mapfile -t konsole_windows < <(qdbus "org.kde.konsole*")
echo "windows:" "$(printf "'%s' " "${konsole_windows[@]}")"
formatted_options=()
# Convert options to the desired format
for i in "${!konsole_windows[@]}"; do
# window_name=$(qdbus "${konsole_windows[$i]}" /MainApplication org.qtproject.Qt.QGuiApplication.applicationDisplayName)
window_title=$(qdbus "${konsole_windows[$i]}" /konsole/MainWindow_1 org.qtproject.Qt.QWidget.windowTitle)
window_sessions_count=$(qdbus "${konsole_windows[$i]}" /Windows/1 org.kde.konsole.Window.sessionCount)
formatted_options+=("$i" "Title: $window_title ($window_sessions_count open tabs)")
((i + 1))
done
# Show dialog to pick a window
selected_window=$(kdialog --title "New Konsole Tab" --menu "Select window to open $DIRECTORY in new tab:" "${formatted_options[@]}")
if [ $? -eq 0 ]; then
# user clicked OK, open new tab in selected window
qdbus "${konsole_windows[$selected_window]}" /Windows/1 org.kde.konsole.Window.newSession "$PROFILE" "$DIRECTORY"
fi
Oh, my bad. I was testing plasma 6 before, reverted to kf5/qt5 and is working now. I didn’t build Konsole from source so probably that was the reason --new-tab wasn’t working for me.
No it’s not. It only opens a new window if the setting “run in a single window” ( process) isn’t ticked ( as mentioned). The orange one is the new tab in the same window.
the easiest and best way i found to do that is just assign a shortcut to “open a new tab” in system settings>shortcuts>konsole, and enabling the “run all Konsole windows in a single process” in konsole configs
I’ve also wanted this feature, and trying to add --new-tab for each app is unfeasible because some are cumbersome to make it to always open in a new tab (example: Dolphin requires a custom .desktop entry to make it always start in a new tab) and some apps require more thinkering, like what @kenning noticed with some terminal apps like fish and htop.
Yes, maybe if you really wanted to you could dig deep into each application option and figure out how to always pass --new-tab to Konsole… but what if we could just force Konsole to always open in a new tab?
So I made a pull request to add a option to Konsole to “Force new tabs”, which is like if you passed --new-tab to every konsole invocation
I can’t link the PR here because my account is new, but it is #1112 on Konsole’s GitLab repository.
The Merge Request has been accepted and (hopefully) it will be included in the next Konsole release!
To make all Konsole invocations to use new tabs, go to Konsole’s settings and enable the “Force new tabs” option. Don’t forget that you also need to enable the “Run all Konsole windows in the same process” too.