Advertisement
harsh7i

Untitled

Aug 21st, 2023
3,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.65 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Variables
  4. red="\e[0;31m";green="\e[0;32m";blue="\e[0;34m";TermDir="${HOME}/.termux";
  5. alert="\e[0;31m\e[1m[∆]";success="\e[0;32m\e[1m[√]";
  6. pearly="\e[0;2m";enc="\e[0;m";lisence="${TermDir}/lisence.txt";
  7.  
  8. bl(){
  9.   while getopts 'rgbpfias:h' opt; do
  10.     case "${opt}" in
  11.       r)var3="\e[0;31m";;g)var3="\e[0;32m";;
  12.       b)var3="\e[0;34m";;p)var3="\e[0;2m";;
  13.       f)var3+="\e[1m";;i)var3+="\e[3m";;
  14.       a)var3="\e[0;31m\e[1m[∆] ";;
  15.       s)var3="\e[0;32m\e[1m[√] ";;
  16.       ?|h)
  17.         echo -e "\e[1mUsage: \e[0;m";
  18.         echo -e " -r  red\n -g  green\n -b  blue\n -p  pearly<Grey>
  19. -f  fearless<Bold>\n -i  italic\n -a  alert\n -s  success";return 1;;
  20.     esac
  21.   done
  22.   if [[ -z "${2}" ]]; then echo -e "\e[0;32m\e[3m\e[1m[√] Hello World\e[0;m";return 1;
  23.   else echo -e "${var3}${2}\e[0;m";return 0;fi
  24. }
  25.  
  26. is_userland(){
  27.   (cd /host-rootfs/data/data/tech.ula/files/home) &> /dev/null 2>&1;
  28.   if [[ "${?}" != 0 ]]; then return 1;else return 0;fi
  29. }
  30.  
  31. pkg_build(){
  32.   local pkg_info=${1};
  33.   echo;bl -s "Installing ${pkg_info}...";echo -e "\e[0;2m\e[0;2m"
  34.   if [[ -d "/host-rootfs/data/data/tech.ula/files" ]]; then
  35.     if [[ $(cat ${lisence}) == *"zsh:True"* ]]; then
  36.       apt install "${pkg_info}" -y;
  37.     else sudo apt install "${pkg_info}" -y;fi
  38.   else apt install "${pkg_info}" -y;fi
  39.   if [[ "${?}" != 0 ]]; then echo;bl -a "Package Installation Failed...";echo;doend;fi
  40.   echo -ne "${enc}";return 0;
  41. }
  42.  
  43. dnrepo(){
  44.   local _repo_link=${1};local _file_link="${2}";local prova="git clone https://github.com/"; # prova = process variable
  45.   if [[ -z "${_repo_link}" ]]; then echo;bl -a "Repository parameter is Empty...";echo;return 1;fi
  46.   if [[ -z "${_file_link}" ]]; then echo;bl -a "File parameter is Empty...";echo;return 1;fi
  47.   prova+="${_repo_link}.git ${_file_link} --depth 1";
  48.   echo;bl -s "Cloning ${_repo_link}...";echo -e "${pearly}";eval "${prova}";
  49.   if [[ "${?}" != 0 ]]; then echo;bl -a "Repository Download Failed...";echo;doend;fi
  50.   echo -ne "${enc}";return 0;
  51. }
  52.  
  53. banner(){
  54.   echo "
  55. ╔═╗╔╦╗╦═╗╔═╗╔╗╔╔═╗╔═╗
  56. ╚═╗ ║ ╠╦╝╠═╣║║║║ ╦║╣
  57. ╚═╝ ╩ ╩╚═╩ ╩╝╚╝╚═╝╚═╝
  58.  ";
  59.   echo "Start coding with yourself.";echo "---------------------------";
  60. }
  61.  
  62. lisence_exist(){
  63.   if [[ ! -f "${lisence}" ]]; then return 1;fi
  64.   if [[ $(cat ${lisence}) == *"Author:Harsh B"* ]]; then return 0;else return 1;fi
  65. }
  66.  
  67. TermDir_Download(){
  68.   if [[ -d "${TermDir}" ]]; then mv "${TermDir}" "${TermDir}.bak.$(date +%Y.%m.%d-%H:%M:%S)";fi
  69.   if [[ ! -f "TermUi.zip" ]]; then
  70.     local prova="wget https://github.com/OurCodeBase/TermUi/raw/main/TermUi.zip";
  71.     echo;bl -s "Downloading File...";echo -e "${pearly}${pearly}";(eval "${prova}");
  72.     if [[ "${?}" != 0 ]]; then echo;bl -a "Download Failed...";echo;doend;fi
  73.     echo -e "${enc}";
  74.   else echo;fi
  75.   bl -s "Unpacking Files...";echo -e "${pearly}";(unzip -d ${HOME} TermUi.zip);
  76.   if [[ "${?}" != 0 ]]; then echo;bl -a "Unpacking Failed...";echo;doend;fi
  77.   echo -ne "${enc}";rm TermUi.zip;echo "TermDir:True" >> ${lisence};return 0;
  78. }
  79.  
  80. install_zsh_autocompl(){
  81.   if ! lisence_exist; then TermDir_Download;fi
  82.   if [[ $(cat ${lisence}) != *"zsh_autocompl:True"* ]]; then
  83.     if [[ ! -d "${HOME}/.zsh-autocomplete" ]]; then
  84.     dnrepo "marlonrichert/zsh-autocomplete" "${HOME}/.zsh-autocomplete";fi
  85.     echo "source ${HOME}/.zsh-autocomplete/zsh-autocomplete.plugin.zsh" >> "${HOME}/.zshrc";
  86.     echo "zsh_autocompl:True" >> ${lisence};
  87.     echo;bl -s "Please restart your session...";echo;doend; return 0;
  88.   else echo;bl -s "Zsh Autocompletion is already installed...";echo;doend;fi
  89. }
  90.  
  91. install_zsh_syntax(){
  92.   if ! lisence_exist; then TermDir_Download;fi
  93.   if [[ $(cat ${lisence}) != *"zsh_syntax:True"* ]]; then
  94.     if [[ ! -d "${HOME}/.zsh-syntax-highlighting" ]]; then
  95.     dnrepo "zsh-users/zsh-syntax-highlighting" "${HOME}/.zsh-syntax-highlighting";fi
  96.     echo "source ${HOME}/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> "${HOME}/.zshrc";
  97.     echo "zsh_syntax:True" >> ${lisence};
  98.     echo;bl -s "Please restart your session...";echo;doend;
  99.   else echo;bl -s "Zsh Syntax Highlighting is already installed...";echo;doend;fi
  100. }
  101.  
  102. install_ohmyzsh(){
  103.   if ! lisence_exist; then TermDir_Download;fi
  104.   if [[ $(cat ${lisence}) != *"ohmyzsh:True"* ]]; then
  105.     if [[ ! -d "${HOME}/.oh-my-zsh" ]]; then
  106.     pkg_build git;dnrepo "ohmyzsh/ohmyzsh" "${HOME}/.oh-my-zsh";fi
  107.     if [[ -f "${HOME}/.zshrc" ]]; then
  108.     mv "${HOME}/.zshrc" "${HOME}/.zshrc.bak.$(date +%Y.%m.%d-%H:%M:%S)";fi
  109.     cp "${HOME}/.oh-my-zsh/templates/zshrc.zsh-template" "${HOME}/.zshrc";
  110.     echo "ohmyzsh:True" >> ${lisence};fi
  111.   local theme_array=();cd "${HOME}/.oh-my-zsh/themes";
  112.   for file in *.zsh-theme ; do theme_array=(${theme_array[@]} "${file}");done;local i=0;
  113.   cd;echo;for obj in ${theme_array[@]} ; do obj=${obj/".zsh-theme"/};echo "[$((i++))] ${obj}";done;
  114.   echo;read -p ">> " choice;
  115.   if [[ "${choice}" -ge "${#theme_array[@]}" ]]; then
  116.   echo;bl -a "Invalid Input...";echo;return 1;fi
  117.   sed -i '/^ZSH_THEME/d' "${HOME}/.zshrc";local var4='1iZSH_THEME="index"';
  118.   local var5=${var4/"index"/"${theme_array[${choice}]}"};local var6=${var5/".zsh-theme"/};
  119.  sed -i "${var6}" "${HOME}/.zshrc";
  120.  echo;bl -s "Please restart your session...";echo;
  121.  unset file obj choice theme_array;return 0;
  122. }
  123.  
  124. install_zsh(){
  125.  if ! lisence_exist; then TermDir_Download;fi
  126.  if [[ $(cat ${lisence}) == *"zsh:True"* ]]; then
  127.  echo;bl -s "Zsh is already installed...";echo;doend;
  128.  else pkg_build zsh;
  129.    if is_userland; then
  130.    echo "su" >> /home/user/.bashrc;echo "/bin/zsh" >> /root/.bashrc;
  131.    if [[ ${?} == 0 ]]; then echo "zsh:True" >> ${lisence};fi
  132.    mv "/home/user/.termux" "/root/" &> /dev/null;
  133.    if [[ -f "/home/user/.zshrc" ]]; then mv /home/user/.zshrc /root/;fi
  134.    echo;bl -s "Please restart your Userland session...";echo;doend;return 0;
  135.    else chsh -s zsh;
  136.    if [[ ${?} == 0 ]]; then echo "zsh:True" >> ${lisence};fi
  137.    echo;bl -s "Please restart your Termux session...";echo;doend;return 0;
  138.    fi
  139.  fi
  140. }
  141.  
  142. install_color(){
  143.  if ! lisence_exist; then TermDir_Download;starter;return 1;fi
  144.  echo;local color_array=();cd "${TermDir}/colors";local i=0;
  145.  for file in *.properties ; do color_array=(${color_array[@]} "${file}");done;cd;
  146.  for obj in ${color_array[@]} ; do
  147.  obj=${obj/".properties"/};echo "[$((i++))] ${obj}";done;
  148.  echo;read -p ">> " choice;
  149.  if [[ "${choice}" -ge "${#color_array[@]}" ]]; then
  150.  echo;bl -a "Invalid Input...";echo;return 1;fi
  151.  if is_userland; then
  152.  local hostdir="/host-rootfs/data/data/tech.ula/files/home";mkdir -p ${hostdir}/.termux;
  153.  (yes | cp -f "${TermDir}/colors/${color_array[${choice}]}" "${hostdir}/.termux/colors.properties") &> /dev/null;
  154.  echo;bl -s "Please restart Userland session...";echo;
  155.  unset file obj choice;return 0;
  156.  else yes | cp "${TermDir}/colors/${color_array[${choice}]}" "${TermDir}/colors.properties";
  157.  eval "termux-reload-settings";echo;
  158.  echo;bl -s "Please restart Termux session...";echo;
  159.  unset file obj choice;return 0;fi
  160. }
  161.  
  162. install_font(){
  163.  if ! lisence_exist; then TermDir_Download;starter;return 1;fi
  164.  echo;local font_array=();cd "${TermDir}/fonts";local i=0;
  165.  for file in *.ttf ; do font_array=(${font_array[@]} "${file}");done;cd;
  166.  for obj in ${font_array[@]} ; do
  167.  local obj=${obj/".ttf"/};echo "[$((i++))] ${obj}";done;
  168.  echo;read -p ">> " choice;
  169.  if [[ "${choice}" -ge "${#font_array[@]}" ]]; then
  170.  echo;bl -a "Invalid Input...";echo;return 1;fi
  171.  if is_userland; then
  172.  local hostdir="/host-rootfs/data/data/tech.ula/files/home";mkdir -p ${hostdir}/.termux;
  173.  (yes | cp -f "${TermDir}/fonts/${font_array[${choice}]}" "${hostdir}/.termux/font.ttf") &> /dev/null;
  174.  echo;bl -s "Please restart Userland session...";echo;
  175.  unset file obj choice;return 0;
  176.  else yes | cp "${TermDir}/fonts/${font_array[${choice}]}" "${TermDir}/font.ttf";
  177.  eval "termux-reload-settings";echo;
  178.  echo;bl -s "Please restart Termux session...";echo;
  179.  unset file obj choice;return 0;fi
  180. }
  181.  
  182. doend(){
  183.  unset red green blue success alert;
  184.  unset pearly TermDir lisence enc var3;
  185.  unset funcs choice;
  186.  exit;
  187. }
  188.  
  189. starter(){
  190.  cd;banner;local i=0;echo;
  191.  echo "[0] Install Fonts";echo "[1] Install Colors";
  192.  echo "[2] Install Zsh";echo "[3] Install OhMyZsh";
  193.  echo "[4] Install Zsh Syntax Highlighting";
  194.  echo "[5] Install Zsh Autocompletion";
  195.  echo "[6] Exit";echo;read -p ">> " choice;
  196.  case ${choice} in
  197.    0)install_font;;1)install_color;;
  198.    2)install_zsh;;3)install_ohmyzsh;;4)install_zsh_syntax;;
  199.    5)install_zsh_autocompl;;6)echo;doend;;
  200.    *)echo;bl -a "Invalid Input...";echo;return 1;;esac
  201. }
  202.  
  203. starter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement