Last active
February 28, 2020 09:48
-
-
Save chetanmeh/5676141 to your computer and use it in GitHub Desktop.
Script to launch a KDE Konsole window with multiple tabs. It is based on script provided in [Linux Journal](http://www.linuxjournal.com/content/start-and-control-konsole-dbus). It helps to bootstrap development env by launching multiple tabs with preconfigured directory and titles.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/path/to/tabs.sh | |
load-dev(){ | |
#Create sessi data format '<Tab Name/Title> <Profile Name> <Working Directory>' | |
local sessions=( | |
oak Shell 'clear; cd ~/git/apache/oak' | |
sling Shell 'clear; cd ~/git/apache/sling' | |
felix Shell 'clear; cd ~/git/apache/felix' | |
) | |
start_sessions sessions[@] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Based on http://www.linuxjournal.com/content/start-and-control-konsole-dbus | |
##################################################################### | |
# Start sessions in konsole. | |
function start_sessions() | |
{ | |
#The passed argument is an array so capture it in a variable | |
declare -a sessions=("${!1}") | |
local nsessions=0 | |
local session_count=${#sessions[*]} | |
local i=0 | |
while [[ $i -lt $session_count ]] | |
do | |
local name=${sessions[$i]} | |
let i++ | |
local profile=${sessions[$i]} | |
let i++ | |
local command=${sessions[$i]} | |
let i++ | |
echo "Creating $name: $command" | |
# Starting with a specific profile appears to be broken. | |
#local session_num=$(qdbus org.kde.konsole /Konsole newSession $profile $HOME) | |
local session_num=$(qdbus org.kde.konsole /Konsole newSession) | |
sleep 0.1 | |
qdbus org.kde.konsole /Sessions/$session_num setTitle 0 $name | |
sleep 0.1 | |
qdbus org.kde.konsole /Sessions/$session_num setTitle 1 $name | |
sleep 0.1 | |
qdbus org.kde.konsole /Sessions/$session_num sendText "$command" | |
sleep 0.1 | |
qdbus org.kde.konsole /Sessions/$session_num sendText $'\n' | |
sleep 0.1 | |
let nsessions++ | |
done | |
# Activate first session. | |
while [[ $nsessions -gt 1 ]] | |
do | |
qdbus org.kde.konsole /Konsole prevSession | |
let nsessions-- | |
done | |
} |
Works fine for me as well, thanks!
Thanks @chetanmeh
This is brilliant! Saved me a ton of work to figure out those clever combinations!
I have forked and added a few more bells and whistles!
https://gist.github.com/codemedic/18589cbe2adef370c9638b463688af67/
can you please create a script that can merge all terminal windows into one window & tabs ?
Thanks for pointing for any hints
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You wrote:
Starting with a specific profile appears to be broken.
local session_num=$(qdbus org.kde.konsole /Konsole newSession $profile $HOME)
Good news: It works perfectly for me ;-) (Kubuntu 13.04)
I run at console
load-dev;exit
And my setup is done.
Thanks!