Skip to content

Instantly share code, notes, and snippets.

@jtsagata
Created January 31, 2011 10:59
Show Gist options
  • Save jtsagata/803899 to your computer and use it in GitHub Desktop.
Save jtsagata/803899 to your computer and use it in GitHub Desktop.
Run all rails tools in a KDE konsole
#!/bin/bash
#
# Create all konsoles with the rails tools!
#
# Create konsole Profiles with names RailsServer, RailsConsole etc..
# Set a static Title and a nice icon
# setTitle is not really working yet ...
# http://www.linuxjournal.com/node/1009239
profile="Rails"
project="/projects/LETS/lets/"
export MY_RAILS_PROJECT=$project
cd $project
killall livereload
killall compass
kill -9 `fuser -n tcp 3000`
#Execute a new konsole
/usr/bin/konsole &
sleep 1
prog=`qdbus | grep org.kde.konsole| tail -1`
echo $prog
sessions=(
'Rails Server' RailsServer 'rails server'
'Rails Console' RailsConsole 'rails console'
'Compass CSS' RailsCSS 'compass --watch'
'Live reload' LiveReload 'livereload'
)
nsessions=0
#####################################################################
# Start sessions in konsole.
function start_sessions()
{
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 $prog /Konsole newSession $profile $project)
sleep 0.1
qdbus $prog /Sessions/$session_num setTitle 0 $name
sleep 0.1
qdbus $prog /Sessions/$session_num setTitle 1 $name
sleep 0.1
qdbus $prog /Sessions/$session_num sendText "$command"
sleep 0.1
qdbus $prog /Sessions/$session_num sendText $'\n'
sleep 0.1
let nsessions++
done
}
start_sessions
# Activate first session.
while [[ $nsessions -gt 1 ]]
do
qdbus $prog /Konsole prevSession
let nsessions--
done
qdbus $prog /Konsole prevSession
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment