Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- pushd `dirname $0` > /dev/null
- projectHomeDir=`pwd -P`
- popd > /dev/null
- ## CONSTANTS
- tde_config_file=".tde.conf"
- ## /CONSTANTS
- ## VARIABLES
- session='MyProject'
- textEditor="vi"
- pane_1_file=null
- pane_2_build_cmd=null
- pane_2_refresh_interval=10
- ## /VARIABLES
- makeConfig() {
- touch ${projectHomeDir}/${tde_config_file}
- echo 'default_text_editor=""' >> ${projectHomeDir}/${tde_config_file}
- echo 'default_pane_1_file=""' >> ${projectHomeDir}/${tde_config_file}
- echo 'build_and_run_test_cmd=""' >> ${projectHomeDir}/${tde_config_file}
- echo 'test_run_interval=""' >> ${projectHomeDir}/${tde_config_file}
- printf "Creating config file....\n"
- sleep 0.5
- printf "Created config file named: ${tde_config_file}\n"
- sleep 0.2
- printf "Starting tde\n"
- sleep 4.3
- }
- loadConfig() {
- while IFS='' read -r line || [[ -n $line ]]; do
- if [[ ${line#*=} != \"\" ]]; then
- tmpVal=${line#*=}
- tmpValLng=${#tmpVal}
- tmpValLng=$((tmpValLng-1))
- tmpVal=${tmpVal:0:$tmpValLng}
- tmpValLng=$((tmpValLng-1))
- tmpVal=${tmpVal:1:$tmpValLng}
- tmpCmd=${line%=*}
- if [[ $tmpCmd == default_text_editor ]]; then
- textEditor=$tmpVal
- fi
- if [[ $tmpCmd == default_pane_1_file ]]; then
- pane_1_file=$tmpVal
- fi
- if [[ $tmpCmd == build_and_run_test_cmd ]]; then
- pane_2_build_cmd=$tmpVal
- fi
- if [[ $tmpCmd == test_run_interval ]]; then
- pane_2_refresh_interval=$tmpVal
- fi
- fi
- done < "${projectHomeDir}/${tde_config_file}"
- }
- processParams() {
- local args=("$@")
- for (( i=0;i<${#args[@]}; i++ )); do
- if [[ ${args[i]} == -f ]]; then
- pane_1_file=${args[i+1]}
- i=$((i+1))
- fi
- if [[ ${args[i]} == -tri ]]; then
- pane_2_refresh_interval=${args[i+1]}
- i=$((i+1))
- fi
- done
- }
- if [ ! -f ${projectHomeDir}/${tde_config_file} ]; then
- makeConfig
- else
- loadConfig
- fi
- processParams $@
- tmux start-server
- tmux new-session -d -s ${session}
- if [[ $textEditor != null && $pane_1_file != null ]]; then
- tmux send-keys "pwd;cd ${projectHomeDir};${textEditor} ${pane_1_file}" C-m
- else
- tmux send-keys "pwd;cd ${projectHomeDir}" C-m
- fi
- tmux split-window -t 0 -h -p 35 -c "$(pwd)"
- tmux select-pane -t 1
- if [[ $pane_2_build_cmd != null && $pane_2_refresh_interval =~ ^-?[0-9+$] ]]; then
- tmux send-keys "watch -n ${pane_2_refresh_interval} -c '${pane_2_build_cmd}'" C-m
- fi
- tmux split-window -t 1 -v -p 40 -c "$(pwd)"
- tmux select-pane -t 2
- tmux send-keys "watch -n 30 -c tree ${projectHomeDir}" C-m
- tmux select-pane -t 0
- tmux -2 attach -t ${session}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement