#!/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"