Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. pushd `dirname $0` > /dev/null
  4. projectHomeDir=`pwd -P`
  5. popd > /dev/null
  6.  
  7. ## CONSTANTS
  8.  
  9. tde_config_file=".tde.conf"
  10.  
  11. ## /CONSTANTS
  12.  
  13.  
  14. ## VARIABLES
  15.  
  16.  
  17. session='MyProject'
  18.  
  19. textEditor="vi"
  20. pane_1_file=null
  21. pane_2_build_cmd=null
  22. pane_2_refresh_interval=10
  23.  
  24. ## /VARIABLES
  25.  
  26. makeConfig() {
  27. touch ${projectHomeDir}/${tde_config_file}
  28.  
  29. echo 'default_text_editor=""' >> ${projectHomeDir}/${tde_config_file}
  30. echo 'default_pane_1_file=""' >> ${projectHomeDir}/${tde_config_file}
  31. echo 'build_and_run_test_cmd=""' >> ${projectHomeDir}/${tde_config_file}
  32. echo 'test_run_interval=""' >> ${projectHomeDir}/${tde_config_file}
  33.  
  34. printf "Creating config file....\n"
  35. sleep 0.5
  36. printf "Created config file named: ${tde_config_file}\n"
  37. sleep 0.2
  38. printf "Starting tde\n"
  39. sleep 4.3
  40. }
  41.  
  42. loadConfig() {
  43. while IFS='' read -r line || [[ -n $line ]]; do
  44. if [[ ${line#*=} != \"\" ]]; then
  45. tmpVal=${line#*=}
  46. tmpValLng=${#tmpVal}
  47. tmpValLng=$((tmpValLng-1))
  48. tmpVal=${tmpVal:0:$tmpValLng}
  49. tmpValLng=$((tmpValLng-1))
  50. tmpVal=${tmpVal:1:$tmpValLng}
  51.  
  52. tmpCmd=${line%=*}
  53. if [[ $tmpCmd == default_text_editor ]]; then
  54. textEditor=$tmpVal
  55. fi
  56.  
  57. if [[ $tmpCmd == default_pane_1_file ]]; then
  58. pane_1_file=$tmpVal
  59. fi
  60.  
  61. if [[ $tmpCmd == build_and_run_test_cmd ]]; then
  62. pane_2_build_cmd=$tmpVal
  63. fi
  64.  
  65. if [[ $tmpCmd == test_run_interval ]]; then
  66. pane_2_refresh_interval=$tmpVal
  67. fi
  68. fi
  69. done < "${projectHomeDir}/${tde_config_file}"
  70. }
  71.  
  72. processParams() {
  73.  
  74. local args=("$@")
  75. for (( i=0;i<${#args[@]}; i++ )); do
  76. if [[ ${args[i]} == -f ]]; then
  77. pane_1_file=${args[i+1]}
  78. i=$((i+1))
  79. fi
  80.  
  81. if [[ ${args[i]} == -tri ]]; then
  82. pane_2_refresh_interval=${args[i+1]}
  83. i=$((i+1))
  84. fi
  85. done
  86.  
  87. }
  88.  
  89.  
  90. if [ ! -f ${projectHomeDir}/${tde_config_file} ]; then
  91. makeConfig
  92. else
  93. loadConfig
  94. fi
  95.  
  96. processParams $@
  97.  
  98. tmux start-server
  99.  
  100. tmux new-session -d -s ${session}
  101.  
  102. if [[ $textEditor != null && $pane_1_file != null ]]; then
  103. tmux send-keys "pwd;cd ${projectHomeDir};${textEditor} ${pane_1_file}" C-m
  104. else
  105. tmux send-keys "pwd;cd ${projectHomeDir}" C-m
  106. fi
  107.  
  108. tmux split-window -t 0 -h -p 35 -c "$(pwd)"
  109.  
  110. tmux select-pane -t 1
  111.  
  112. if [[ $pane_2_build_cmd != null && $pane_2_refresh_interval =~ ^-?[0-9+$] ]]; then
  113. tmux send-keys "watch -n ${pane_2_refresh_interval} -c '${pane_2_build_cmd}'" C-m
  114. fi
  115.  
  116. tmux split-window -t 1 -v -p 40 -c "$(pwd)"
  117.  
  118. tmux select-pane -t 2
  119.  
  120. tmux send-keys "watch -n 30 -c tree ${projectHomeDir}" C-m
  121.  
  122. tmux select-pane -t 0
  123.  
  124. tmux -2 attach -t ${session}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement