From 56c57bbe888ba6d68b3c534787bbb4726db20193 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 4 Jun 2013 15:46:44 +0200 Subject: [PATCH] Initial import. --- README.md | 8 ++++++++ bin/koproj | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ koproj.sample | 47 +++++++++++++++++++++++++++++++++++++++++++++++ lib/base.sh | 24 ++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 README.md create mode 100755 bin/koproj create mode 100755 koproj.sample create mode 100644 lib/base.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef19fc4 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +KoProj is a tool for managing console project environments + +Ex: Project X require 3 terminals, with name A, B, C + A : must be in directory ~/ + B : must be in directory ~/foo + run command X + C : must be in directory ~/bar + run command Y diff --git a/bin/koproj b/bin/koproj new file mode 100755 index 0000000..28ee831 --- /dev/null +++ b/bin/koproj @@ -0,0 +1,51 @@ +#!/bin/sh + + +KOPROJ_DATA_DIR=$(cd `dirname "$0"`; cd ../lib ; pwd ) +KOPROJ_CONFIG_DIR=$HOME/.config/koproj + + . $KOPROJ_DATA_DIR/base.sh + +## Expected usage : +# +# koproj exec +# koproj init +# + +mkdir -p $KOPROJ_CONFIG_DIR +while [ $# -gt 0 ]; do + arg=${1:-} + opt=${2:-} + case $arg in + -l|--list) #list projects + echo "List of projects :" + ls $KOPROJ_CONFIG_DIR/*.koproj 2> /dev/null + ;; + -e) # edit project + shift + project="$opt" + if [ -z "$project" ]; then + echo "ERROR: project name missing" >&2 + exit 1 + elif [ ! -e "$KOPROJ_CONFIG_DIR/$project.koproj" ]; then + echo "ERROR: unknown project $project" >&2 + exit 1 + fi + "$EDITOR" "$KOPROJ_CONFIG_DIR/$project.koproj" + ;; + -c) # create + ;; + -d) # destroy + ;; + *) #enter into project + project="$arg" + if [ ! -e "$KOPROJ_CONFIG_DIR/$project.koproj" ]; then + echo "ERROR: unknown project $project" >&2 + exit 1 + fi + . "$KOPROJ_CONFIG_DIR/$project.koproj" + ;; + esac + shift +done + diff --git a/koproj.sample b/koproj.sample new file mode 100755 index 0000000..7ddae95 --- /dev/null +++ b/koproj.sample @@ -0,0 +1,47 @@ + +PROJECT_ROOT="/path/to/somewhere" +WPTHEME_PATH="$PROJECT_ROOT/wp-root" + +koproj_newtab +koproj_renametab "VAGRANT" +koproj_run "cd $PROJECT_ROOT" +koproj_run "clear" +koproj_run 'sudo /etc/init.d/vboxdrv start' +koproj_run './bin/vagrant up' + +koproj_newtab +koproj_renametab "VM" +koproj_run "cd $PROJECT_ROOT" +koproj_run "clear" + +koproj_newtab +koproj_renametab "FORGE" +koproj_run "cd $WPTHEME_PATH" +koproj_run "clear" +koproj_run "be forge watch" + +koproj_newtab +koproj_renametab "ASSETS" +koproj_run "cd $WPTHEME_PATH/source/assets" +koproj_run "clear" + +koproj_newtab +koproj_renametab "JS" +koproj_run "cd $WPTHEME_PATH/source/assets/javascripts" +koproj_run "clear" + +koproj_newtab +koproj_renametab "CSS" +koproj_run "cd $WPTHEME_PATH/source/assets/stylesheets" +koproj_run "clear" + +koproj_newtab +koproj_renametab "FUNCTIONS" +koproj_run "cd $WPTHEME_PATH/source/functions" +koproj_run "clear" + +koproj_newtab +koproj_renametab "TEMPLATES" +koproj_run "cd $WPTHEME_PATH/source/templates" +koproj_run "clear" + diff --git a/lib/base.sh b/lib/base.sh new file mode 100644 index 0000000..3396f25 --- /dev/null +++ b/lib/base.sh @@ -0,0 +1,24 @@ + +koproj_run() { + local cmd="$*" + qdbus org.kde.konsole /Sessions/${session} sendText "$cmd" + qdbus org.kde.konsole /Sessions/${session} sendText " + " +} + + +koproj_newtab() { + #dbus-send --session --dest=${KONSOLE_DBUS_SERVICE} --type=method_call \ + # --print-reply /konsole/MainWindow_1 org.kde.KMainWindow.activateAction string:"new-tab" + + session=$(qdbus org.kde.konsole /Konsole newSession) +} + +koproj_renametab() { + #sessionno=$1 + tabname=$1 + #session="/Sessions/${sessionno}" + #dbus-send --session --dest=${KONSOLE_DBUS_SERVICE} --type=method_call --print-reply ${session} org.kde.konsole.Session.setTitle int32:1 string:"$tabname" + qdbus org.kde.konsole /Sessions/${session} setTitle 1 "$tabname" +} +