aboutsummaryrefslogtreecommitdiffstats
path: root/bin/atmux
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
committerDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
commit67b0ec5741d327d27afe88783d85fcf2c4c4f204 (patch)
tree4ea47807c5e775927b96eb79933c09fbfcd0468e /bin/atmux
downloaddotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.gz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.bz2
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.xz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.zip
First commit
Diffstat (limited to 'bin/atmux')
-rwxr-xr-xbin/atmux122
1 files changed, 122 insertions, 0 deletions
diff --git a/bin/atmux b/bin/atmux
new file mode 100755
index 0000000..7601693
--- /dev/null
+++ b/bin/atmux
@@ -0,0 +1,122 @@
+#!/bin/bash
+
+if [ -e $HOME/bin/functions.sh ]
+then
+ . $HOME/bin/functions.sh
+else
+ echo "functions.sh not found"
+ exit 0
+fi
+
+# override tmux
+tmux='tmux'
+
+## CONFIGURATION
+# session name
+sn=${1:-atmux}
+
+# try to attach earlier session
+tmux attach-session -t $sn && exit 0
+#or continue
+
+# default path
+case $sn in
+ # window definitions
+ # path:command:custom-name
+ "thesis")
+ dpath=/home/konni/dropbox/documents/uni/12ss/BA/breite-quellen/thesis
+ windows="-:-"
+ windows+="matlab:echo bla"
+ ;;
+ "mako")
+ dpath=/extra/src/cyanogenmod-10.1
+ dcmd=". environment_mako"
+ windows="-:-"
+ windows+="-:-"
+ windows+=" device/lge/mako:-"
+ windows+=" out/target/product/mako:-"
+ ;;
+ "ville_dev")
+ dpath=/extra/src/cyanogenmod-10.1
+ dcmd=". environment_ville"
+ windows="-:-"
+ windows+=" -:-"
+ windows+=" device/htc/ville:-"
+ windows+=" device/htc/msm8960-common:-"
+ windows+=" kernel/htc/msm8960:-"
+ windows+=" vendor/htc:-"
+ windows+=" out/target/product/ville:-"
+ ;;
+ "ville")
+ dpath=/extra/src/cyanogenmod-jellybean
+ dcmd=". environment_ville"
+ windows="-:-"
+ windows+=" -:-"
+ windows+=" device/htc/ville:-"
+ windows+=" device/htc/msm8960-common:-"
+ windows+=" kernel/htc/msm8960:-"
+ windows+=" vendor/htc:-"
+ windows+=" out/target/product/ville:-"
+ ;;
+ *)
+ dpath=$HOME
+ windows="-:-"
+esac
+
+
+# enter default path
+mute pushd $dpath
+
+# prepare windows
+num=1
+for window in $windows
+do
+ # parse configuration
+ read wpath wcmd <<< $(echo $window | sed 's/:/\ /g')
+
+ # set path
+ unset tpath
+ if [ $wpath != "-" ]
+ then
+ tpath=$wpath
+ fi
+
+
+ if [ $num -eq 1 ]
+ then
+ # start new session
+ $tmux new-session -d -s "$sn" $tname
+ # set default path for new windows
+ $tmux set-option -t "$sn" default-path $dpath
+ else
+ # create new window in session
+ $tmux new-window -t "$sn:$num" $tname
+ fi
+
+ # execute default command
+ if [ -n "$dcmd" ]
+ then
+ $tmux send-keys -t "$n:$num" "$dcmd" C-m
+ fi
+
+ # change path
+ if [ -n "$tpath" ]
+ then
+ $tmux send-keys -t "$n:$num" "cd $tpath" C-m
+ fi
+
+ # execute custom command
+ unset tcmd
+ if [ "$wcmd" != "-" ]
+ then
+ tcmd=$wcmd
+ $tmux send-keys -t "$n:$num" "$tcmd" C-m
+ fi
+
+ let num=num+1
+done
+
+# select window #1 and attach to session
+$tmux select-window -t "$sn:1"
+$tmux attach-session -t "$sn"
+