From 085ed152f2acff6f83d080cfb7e9aee28b621761 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 22:41:00 +0700 Subject: [PATCH 01/10] Change structure code installation --- .animation/test.sh | 7 - .../ghost.sh => helper-install/animation.sh | 24 ++- helper-install/banner.sh | 25 +++ helper-install/clone.sh | 95 +++++++++++ helper-install/colors.sh | 7 + helper-install/cursor.sh | 7 + helper-install/dotfiles.sh | 109 ++++++++++++ helper-install/finish.sh | 7 + helper-install/nvchad.sh | 37 +++++ helper-install/package.sh | 64 ++++++++ helper-install/screen.sh | 30 ++++ helper-install/signal.sh | 16 ++ helper-install/stat.sh | 11 ++ helper-install/switchcase.sh | 155 ++++++++++++++++++ helper-install/themes.sh | 66 ++++++++ helper-install/utility.sh | 17 ++ install.sh | 58 ++++++- 17 files changed, 712 insertions(+), 23 deletions(-) delete mode 100755 .animation/test.sh rename .animation/ghost.sh => helper-install/animation.sh (89%) create mode 100755 helper-install/banner.sh create mode 100755 helper-install/clone.sh create mode 100755 helper-install/colors.sh create mode 100755 helper-install/cursor.sh create mode 100755 helper-install/dotfiles.sh create mode 100755 helper-install/finish.sh create mode 100755 helper-install/nvchad.sh create mode 100755 helper-install/package.sh create mode 100755 helper-install/screen.sh create mode 100755 helper-install/signal.sh create mode 100755 helper-install/stat.sh create mode 100755 helper-install/switchcase.sh create mode 100755 helper-install/themes.sh create mode 100755 helper-install/utility.sh diff --git a/.animation/test.sh b/.animation/test.sh deleted file mode 100755 index d40a419..0000000 --- a/.animation/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -source $(pwd)/ghost.sh - -start_ghost "Bash Animation " -sleep 10000s -stop_ghost $? diff --git a/.animation/ghost.sh b/helper-install/animation.sh similarity index 89% rename from .animation/ghost.sh rename to helper-install/animation.sh index 63644de..473a012 100755 --- a/.animation/ghost.sh +++ b/helper-install/animation.sh @@ -37,7 +37,7 @@ ARRAY_ANIMATION=( " ${COLOR_BLUE}${ICON}${COLOR_GREEN}${ICON}${COLOR_RED}${ICON}${COLOR_YELLOW}${ICON}${COLOR_MAGENTA}${ICON}" ) -ghost() { +function animation() { case $1 in @@ -64,7 +64,7 @@ ghost() { stop ) if [[ -z ${3} ]]; then - echo "ghost not running" + echo "Animation not running" exit 1 fi @@ -93,23 +93,19 @@ ghost() { esac } -function start_ghost() { +function start_animation() { - setterm -cursor off - ghost "start" "${1}" & - ghost_pid=${!} + setCursor off + animation "start" "${1}" & + animation_pid=${!} disown } -function stop_ghost() { +function stop_animation() { - ghost "stop" $1 $ghost_pid - unset $ghost_pid - setterm -cursor on + animation "stop" $1 $animation_pid + unset $animation_pid + setCursor on } - -# start_ghost "ncmpcpp" -# sleep 10s -# stop_ghost $? diff --git a/helper-install/banner.sh b/helper-install/banner.sh new file mode 100755 index 0000000..0387597 --- /dev/null +++ b/helper-install/banner.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +VERSION="0.6.0" +BUILD_DATE="19 October 2021" +AUTHOR="xShin" + +function banner() { + + echo -e " + ┌────────────────────────────────────────────────────────────────┐ + │ _______ │ + │ (_______) │ + │ ____ _ _ _ _____ ____ ____ _ _ _ _ │ + │ | \| | | | | ___ |/ ___) \| | | ( \ / ) │ + │ | | | | |_| | | ____| | | | | | |_| |) X ( │ + │ |_|_|_|\__ |_|_____)_| |_|_|_|____/(_/ \_) │ + │ (____/ │ + │ │ + │ 🚀 Version : ${VERSION} │ + │ 📅 Build Date : ${BUILD_DATE} │ + │ ⚙️ Author : ${AUTHOR} │ + │ │ + ╰────────────────────────────────────────────────────────────────╯ + " +} \ No newline at end of file diff --git a/helper-install/clone.sh b/helper-install/clone.sh new file mode 100755 index 0000000..789f00b --- /dev/null +++ b/helper-install/clone.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +REPOSITORY_LINKS=( + https://github.com/robbyrussell/oh-my-zsh + https://github.com/zsh-users/zsh-syntax-highlighting + https://github.com/zsh-users/zsh-autosuggestions + https://github.com/jimeh/tmux-themepack + https://github.com/NvChad/NvChad +) + +REPOSITORY_APIS=( + repositories/291137 + repos/zsh-users/zsh-syntax-highlighting + repos/zsh-users/zsh-autosuggestions + repos/jimeh/tmux-themepack + repos/NvChad/NvChad +) + +REPOSITORY_FULL_NAME=( + robbyrussell/oh-my-zsh + zsh-users/zsh-syntax-highlighting + zsh-users/zsh-autosuggestions + jimeh/tmux-themepack + siduck76/NvChad +) + +REPOSITORY_PATH=( + $HOME/.oh-my-zsh/ + $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting + $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions + $HOME/.tmux-themepack + $HOME/NvChad +) + +function repoSize() { + + echo "$(echo "scale=2 + $(curl https://api.github.com/$@ 2>/dev/null | grep size | head -1 | tr -dc '[:digit:]') / 1024" | bc)MB" + +} + +function repositories() { + + setCursor off + + echo -e "‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Repository" + sleep 2s + + echo -e " + ╭────────────────────────────────────────────────────────────────────╮ + ┃ Information Repository ┃ + ╰────────────────────────────────────────────────────────────────────╯ + ┃ Repository Name ┃ Repository Size ┃ + ╰────────────────────────────────────────────────────────────────────╯" + + for REPOSITORY_API in "${REPOSITORY_APIS[@]}"; do + + REPOSITORY_NAME=$(curl https://api.github.com/${REPOSITORY_API} 2> /dev/null | grep full_name | awk '{print $2}' | sed "s/,//g" | sed "s/\"//g") + printf " ┃ ${COLOR_SUCCESS}%-36s${COLOR_BASED} ▎ ${COLOR_WARNING}%8s${COLOR_BASED} ┃\n" $REPOSITORY_NAME `repoSize $REPOSITORY_API` + + done + + echo " ╰────────────────────────────────────────────────────────────────────╯" + echo -e "" + +} + +function cloneRepository() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Clone or Downloading Repository\n" + sleep 2s + + for ((i=0; i<${#REPOSITORY_LINKS[@]}; i++)); do + + start_animation " Cloning ${COLOR_WARNING}'${COLOR_SUCCESS}${REPOSITORY_FULL_NAME[i]}${COLOR_WARNING}'${COLOR_BASED} ..." + + git clone ${REPOSITORY_LINKS[i]} ${REPOSITORY_PATH[i]} 2> /dev/null + + if [ -d ${REPOSITORY_PATH[i]} ]; then + + stop_animation $? || exit 1 + + else + + stop_animation $? + + fi + + done + + setCursor on + +} \ No newline at end of file diff --git a/helper-install/colors.sh b/helper-install/colors.sh new file mode 100755 index 0000000..1d63d66 --- /dev/null +++ b/helper-install/colors.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +COLOR_BASED="\e[39m" +COLOR_DANGER="\e[91m" +COLOR_WARNING="\e[93m" +COLOR_SUCCESS="\e[92m" +COLOR_SKY="\e[34m" \ No newline at end of file diff --git a/helper-install/cursor.sh b/helper-install/cursor.sh new file mode 100755 index 0000000..b51c388 --- /dev/null +++ b/helper-install/cursor.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +function setCursor() { + + setterm -cursor ${1} + +} \ No newline at end of file diff --git a/helper-install/dotfiles.sh b/helper-install/dotfiles.sh new file mode 100755 index 0000000..35ac013 --- /dev/null +++ b/helper-install/dotfiles.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +DOTFILES=( + .autostart .aliases + .config .color-toys + .local .scripts + .termux .tmux.conf + .zshrc +) + +BACKUP_DOTFILES=( + .autostart .aliases + .config .color-toys + .local .scripts + .termux .tmux.conf + .zshrc .oh-my-zsh +) + +function dotFiles() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Dotfiles" + sleep 2s + + echo -e " + ╭───────────────────────────────────────────────╮ + ┃ Information Dotfiles ┃ + ╰───────────────────────────────────────────────╯ + ┃ Folder Name ┃ Folder Size ┃ + ╰───────────────────────────────────────────────╯" + + for DOTFILE in "${DOTFILES[@]}"; do + + FOLDER_SIZE=$(du -s -h $DOTFILE | awk '{print $1}') + printf " ┃ ${COLOR_SUCCESS}%-12s${COLOR_BASED} ▎ ${COLOR_WARNING}%5s${COLOR_BASED} ┃\n" $DOTFILE $FOLDER_SIZE + + done + + echo " ╰───────────────────────────────────────────────╯ + " + +} + +function backupDotFiles() { + + echo -e "‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Backup Dotfiles" + echo -e "" + sleep 2s + + for BACKUP_DOTFILE in "${BACKUP_DOTFILES[@]}"; do + + start_animation " Backup ${COLOR_SUCCESS}${BACKUP_DOTFILE}${COLOR_BASED} ..." + sleep 1s + + if [[ -d "$HOME/$BACKUP_DOTFILE" || -f "$HOME/$BACKUP_DOTFILE" ]]; then + + mv ${HOME}/${BACKUP_DOTFILE} ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S).backup + + if [[ -d ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S).backup || -f ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S).backup ]]; then + + stop_animation $? || exit 1 + + else + + stop_animation $? + + fi + + else + + stop_animation $? + + fi + + done + + echo -e "" + +} + +function installDotFiles() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing Dotfiles\n" + + for DOTFILE in "${DOTFILES[@]}"; do + + start_animation " Installing ${COLOR_WARNING}'${COLOR_SUCCESS}${DOTFILE}${COLOR_WARNING}'${COLOR_BASED} ..." + cp -R $DOTFILE $HOME + + if [[ -d $HOME/$DOTFILE || -f $HOME/$DOTFILE ]]; then + + stop_animation $? || exit 1 + + else + + stop_animation $? + + fi + + done + + echo -e "" + + setCursor on + +} \ No newline at end of file diff --git a/helper-install/finish.sh b/helper-install/finish.sh new file mode 100755 index 0000000..099bdef --- /dev/null +++ b/helper-install/finish.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +function alertFinish() { + + echo -e "‏‏‎‏‏‎\n ‎‏‏‎ ⚠️ Installation Finish, but you need restart Termux to clear setup\n" + +} \ No newline at end of file diff --git a/helper-install/nvchad.sh b/helper-install/nvchad.sh new file mode 100755 index 0000000..74b36e5 --- /dev/null +++ b/helper-install/nvchad.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +function NvChad() { + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing Neovim Plugins with Packer\n" + + stat "CHECK" "Warning" "NvChad Folder" + + if [ -d $HOME/NvChad ]; then + + stat "RESULT" "Success" "NvChad exist" + + stat "RUN" "Warning" "Move NvChad Folder to .config/nvim ..." + + mv $HOME/NvChad $HOME/.config/nvim + + if [ -d $HOME/.config/nvim ]; then + + stat "RESULT" "Success" "NvChad success move to .config/nvim" + + stat "RUN" "Warning" "Installing NvChad" + + nvim +'hi NormalFloat guibg=#1e222a' +PackerSync + + else + + stat "RESULT" "Danger" "NvChad failed move to .config/nvim" + + fi + + else + + stat "RESULT" "Danger" "NvChad No such directory" + + fi + +} \ No newline at end of file diff --git a/helper-install/package.sh b/helper-install/package.sh new file mode 100755 index 0000000..d058082 --- /dev/null +++ b/helper-install/package.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +PACKAGES=( + bat curl clang exa git imagemagick + inotify-tools lf mpd mpc neovim + neofetch termux-api tmux zsh +) + +function packages() { + + setCursor off + + echo -e "‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Packages" + echo -e " + ╭─────────────────────────────────────────────────────────────────────────────────────╮ + ┃ Information Packages ┃ + ╰─────────────────────────────────────────────────────────────────────────────────────╯ + ┃ Package Name ┃ Version ┃ Download ┃ Installed ┃ + ╰─────────────────────────────────────────────────────────────────────────────────────╯" + + for PACKAGE in "${PACKAGES[@]}"; do + + PACKAGE_NAME=$(apt show $PACKAGE 2> /dev/null | grep Package: | awk '{print $2}') + VERSION=$(apt show $PACKAGE 2> /dev/null | grep Version: | awk '{print $2}') + DOWNLOAD_SIZE=$(apt show $PACKAGE 2> /dev/null | grep Download-Size: | awk '{print $2$3}') + INSTALLED_SIZE=$(apt show $PACKAGE 2> /dev/null | grep Installed-Size: | awk '{print $2$3}') + printf " ┃ ${COLOR_SUCCESS}%-13s${COLOR_BASED} ▎ ${COLOR_WARNING}%10s${COLOR_BASED} ▎ ${COLOR_WARNING}%6s${COLOR_BASED} ▎ ${COLOR_WARNING}%6s${COLOR_BASED} ┃\n" $PACKAGE_NAME $VERSION $DOWNLOAD_SIZE $INSTALLED_SIZE + + done + + echo -e " ╰─────────────────────────────────────────────────────────────────────────────────────╯ + " + +} + +function installPackages() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Downloading Packages\n" + + for PACKAGE in "${PACKAGES[@]}"; do + + start_animation " Installing ${COLOR_WARNING}'${COLOR_SUCCESS}${PACKAGE}${COLOR_WARNING}'${COLOR_BASED} ..." + + pkg i -y $PACKAGE &>/dev/null + THIS_PACKAGE=$(pkg list-installed $PACKAGE 2> /dev/null | tail -n 1) + CHECK_PACKAGE=${THIS_PACKAGE%/*} + + if [[ $CHECK_PACKAGE == $PACKAGE ]]; then + + stop_animation $? || exit 1 + + else + + stop_animation $? + + fi + + done + + setCursor on + +} \ No newline at end of file diff --git a/helper-install/screen.sh b/helper-install/screen.sh new file mode 100755 index 0000000..b4e3e68 --- /dev/null +++ b/helper-install/screen.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +COLS=$(echo $COLUMNS) +ROWS=$(echo $LINES) + +function screenSize() { + + if [[ -n ${COLS} && -n ${ROWS} ]]; then + + if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then + + ${1} + + elif (( ${COLS} <= 101 & ${ROWS} <= 42 )); then + + stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" + + else + + stat "ERROR" "Danger" "Unknown ERROR!!!" + + fi + + else + + stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" + + fi + +} \ No newline at end of file diff --git a/helper-install/signal.sh b/helper-install/signal.sh new file mode 100755 index 0000000..5501010 --- /dev/null +++ b/helper-install/signal.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +function handleInterruptByUser() { + + pkill com.termux + + echo -e " + \n [ ${COLOR_WARNING}ERROR${COLOR_BASED} ] > ${COLOR_DANGER}${1}${COLOR_BASED}\n" + + setCursor on + + read -n 1 -s -r -p " Press any key to exit " + + exit 1 + +} \ No newline at end of file diff --git a/helper-install/stat.sh b/helper-install/stat.sh new file mode 100755 index 0000000..f13f3b2 --- /dev/null +++ b/helper-install/stat.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +function stat() { + if [ "${2}" == "Success" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_SUCCESS}${3}${COLOR_BASED}" + elif [ "${2}" == "Warning" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_WARNING}${3}${COLOR_BASED}" + elif [ "${3}" == "Danger" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_DANGER}${3}${COLOR_BASED}" + fi +} \ No newline at end of file diff --git a/helper-install/switchcase.sh b/helper-install/switchcase.sh new file mode 100755 index 0000000..5cc07da --- /dev/null +++ b/helper-install/switchcase.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash + +function switchCase() { + + setCursor on + + read -p " ${1} ${2}? [Y/n] " SWITCH_CASE + + case "$SWITCH_CASE" in + + "" ) + ${3} + ;; + + y|Y ) + ${3} + ;; + + n|N ) + echo -e "Nnaaahh" + + ;; + + * ) + echo -e "ERROR" + ;; + + esac + +} + +function caseInstallPackage() { + + read -p " Do you want to install the packages? [Y/n] " INSTALL_PACKAGES + + case "$INSTALL_PACKAGES" in + + "" ) + installPackages + ;; + + y|Y ) + installPackages + ;; + + n|N ) + echo -e "No" + ;; + + * ) + echo -e "Unknown" + ;; + + esac + +} + +function caseBackupDotFiles() { + + read -p " Do you want to backup the dotfiles? [Y/n] " BACKUP_DOTFILES + + if [ "${BACKUP_DOTFILES}" == "" ]; then + + backupDotFiles + + elif [ "${BACKUP_DOTFILES}" == "y" ]; then + + backupDotFiles + + else + + exit + + fi + +} + +function caseInstallDotfiles() { + + read -p " Do you want to install dotfiles? [Y/n] " INSTALL_DOTFILES + + case "$INSTALL_DOTFILES" in + + "" ) + installDotFiles + ;; + + y|Y ) + installDotFiles + ;; + + n|N ) + echo -e "No" + ;; + + * ) + echo -e "Unknown" + ;; + + esac + +} + +function caseCloneRepository() { + + read -p " Do you want to clone repository? [Y/n] " CLONE_REPOSITORY + + case "$CLONE_REPOSITORY" in + + "" ) + cloneRepository + ;; + + y|Y ) + cloneRepository + ;; + + n|N ) + echo -e "No" + ;; + + * ) + echo -e "Unknown" + ;; + + esac + +} + +function caseInstallZshTheme() { + + read -p " Do you want to install ZSH Theme? [Y/n] " INSTALL_ZSH_THEME + + case "$INSTALL_ZSH_THEME" in + + "" ) + installZshTheme + ;; + + y|Y ) + installZshTheme + ;; + + n|N ) + echo -e "No" + ;; + + * ) + echo -e "Unknown" + ;; + + esac + +} + diff --git a/helper-install/themes.sh b/helper-install/themes.sh new file mode 100755 index 0000000..a7a131b --- /dev/null +++ b/helper-install/themes.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +ZSH_CUSTOM_THEMES=( + osx.zsh-theme + archcraft.zsh-theme + ar-round.zsh-theme + la-round.zsh-theme + rounded-custom.zsh-theme + rounded.zsh-theme +) + +function zshTheme() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information ZSH Theme" + sleep 2s + + echo -e " + ╭─────────────────────────────────────────────────────────╮ + ┃ Information ZSH Theme ┃ + ╰─────────────────────────────────────────────────────────╯ + ┃ File Name ┃ File Size ┃ + ╰─────────────────────────────────────────────────────────╯" + + for ZSH_CUSTOM_THEME in "${ZSH_CUSTOM_THEMES[@]}"; do + + FILE_SIZE=$(du -s -h .oh-my-zsh/custom/themes/$ZSH_CUSTOM_THEME | awk '{print $1}') + printf " ┃ ${COLOR_SUCCESS}%-24s${COLOR_BASED} ▎ ${COLOR_WARNING}%5s${COLOR_BASED} ┃\n" $ZSH_CUSTOM_THEME $FILE_SIZE + + done + + echo " ╰─────────────────────────────────────────────────────────╯ + " + +} + +function installZshTheme() { + + setCursor off + + echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing ZSH Custom Themes\n" + + PATHDIR=".oh-my-zsh/custom/themes" + + for ZSH_CUSTOM_THEME in "${ZSH_CUSTOM_THEMES[@]}"; do + + start_animation " Installing ${COLOR_WARNING}'${COLOR_SUCCESS}${ZSH_CUSTOM_THEME}${COLOR_WARNING}'${COLOR_BASED} ..." + sleep 2s + cp $(pwd)/${PATHDIR}/${ZSH_CUSTOM_THEME} $HOME/${PATHDIR}/${ZSH_CUSTOM_THEME} + + if [ -f $HOME/$PATHDIR/$ZSH_CUSTOM_THEME ]; then + + stop_animation $? || exit 1 + + else + + stop_animation $? + + fi + + done + + setCursor on + +} \ No newline at end of file diff --git a/helper-install/utility.sh b/helper-install/utility.sh new file mode 100755 index 0000000..f18fe00 --- /dev/null +++ b/helper-install/utility.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +function utility() { + + termux-reload-settings + + cp ~/.termux/fonts/NerdFonts/JetBrains/JetBrains\ Mono\ Medium\ Nerd\ Font\ Complete.ttf $PREFIX/share/fonts/TTF/ 2> /dev/null + + chsh -s zsh + + if [[ -f $PREFIX/etc/motd ]]; then + + mkdir $HOME/motd/ + mv $PREFIX/etc/motd $HOME/motd/motd.backup + + fi +} \ No newline at end of file diff --git a/install.sh b/install.sh index 84abdd7..4e0a3b5 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,59 @@ #!/usr/bin/env bash -source $(pwd)/.functions.sh +HELPERS=( + colors animation banner package switchcase + dotfiles clone themes nvchad utility + stat signal screen cursor finish +) -main \ No newline at end of file +for HELPER in ${HELPERS[@]}; do + source $(pwd)/helper-install/${HELPER}.sh +done + +# # Done +# banner +# packages +# caseInstallPackage +# dotFiles + +# # Error Array +# #caseBackupDotFiles + +# # Done +# backupDotFiles +# caseInstallDotfiles + +# cloneRepositories +# caseCloneRepository + +# zshTheme +# caseInstallZshTheme + +# NvChad +# utility + +function main() { + + trap 'handleInterruptByUser "Interrupt by User"' 2 + + banner + + packages + switchCase "Install" "Packages" installPackages + + dotFiles + backupDotFiles + switchCase "Install" "Dotfiles" installDotFiles + + repositories + switchCase "Clone" "Repositories" cloneRepository + + zshTheme + switchCase "Install" "ZSH Themes" installZshTheme + + NvChad + utility + +} + +screenSize main \ No newline at end of file From 97076e53a114bdc65fbd7925ea8958a843f5f0f2 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 22:51:48 +0700 Subject: [PATCH 02/10] Change structure code installation with Human Readable xD --- {helper-install => helper_install}/animation.sh | 0 {helper-install => helper_install}/banner.sh | 0 {helper-install => helper_install}/clone.sh | 0 {helper-install => helper_install}/colors.sh | 0 {helper-install => helper_install}/cursor.sh | 0 {helper-install => helper_install}/dotfiles.sh | 0 {helper-install => helper_install}/finish.sh | 0 {helper-install => helper_install}/nvchad.sh | 0 {helper-install => helper_install}/package.sh | 0 {helper-install => helper_install}/screen.sh | 0 {helper-install => helper_install}/signal.sh | 0 {helper-install => helper_install}/stat.sh | 8 ++++++++ {helper-install => helper_install}/switchcase.sh | 0 {helper-install => helper_install}/themes.sh | 0 {helper-install => helper_install}/utility.sh | 0 install.sh | 2 +- 16 files changed, 9 insertions(+), 1 deletion(-) rename {helper-install => helper_install}/animation.sh (100%) rename {helper-install => helper_install}/banner.sh (100%) rename {helper-install => helper_install}/clone.sh (100%) rename {helper-install => helper_install}/colors.sh (100%) rename {helper-install => helper_install}/cursor.sh (100%) rename {helper-install => helper_install}/dotfiles.sh (100%) rename {helper-install => helper_install}/finish.sh (100%) rename {helper-install => helper_install}/nvchad.sh (100%) rename {helper-install => helper_install}/package.sh (100%) rename {helper-install => helper_install}/screen.sh (100%) rename {helper-install => helper_install}/signal.sh (100%) rename {helper-install => helper_install}/stat.sh (97%) rename {helper-install => helper_install}/switchcase.sh (100%) rename {helper-install => helper_install}/themes.sh (100%) rename {helper-install => helper_install}/utility.sh (100%) diff --git a/helper-install/animation.sh b/helper_install/animation.sh similarity index 100% rename from helper-install/animation.sh rename to helper_install/animation.sh diff --git a/helper-install/banner.sh b/helper_install/banner.sh similarity index 100% rename from helper-install/banner.sh rename to helper_install/banner.sh diff --git a/helper-install/clone.sh b/helper_install/clone.sh similarity index 100% rename from helper-install/clone.sh rename to helper_install/clone.sh diff --git a/helper-install/colors.sh b/helper_install/colors.sh similarity index 100% rename from helper-install/colors.sh rename to helper_install/colors.sh diff --git a/helper-install/cursor.sh b/helper_install/cursor.sh similarity index 100% rename from helper-install/cursor.sh rename to helper_install/cursor.sh diff --git a/helper-install/dotfiles.sh b/helper_install/dotfiles.sh similarity index 100% rename from helper-install/dotfiles.sh rename to helper_install/dotfiles.sh diff --git a/helper-install/finish.sh b/helper_install/finish.sh similarity index 100% rename from helper-install/finish.sh rename to helper_install/finish.sh diff --git a/helper-install/nvchad.sh b/helper_install/nvchad.sh similarity index 100% rename from helper-install/nvchad.sh rename to helper_install/nvchad.sh diff --git a/helper-install/package.sh b/helper_install/package.sh similarity index 100% rename from helper-install/package.sh rename to helper_install/package.sh diff --git a/helper-install/screen.sh b/helper_install/screen.sh similarity index 100% rename from helper-install/screen.sh rename to helper_install/screen.sh diff --git a/helper-install/signal.sh b/helper_install/signal.sh similarity index 100% rename from helper-install/signal.sh rename to helper_install/signal.sh diff --git a/helper-install/stat.sh b/helper_install/stat.sh similarity index 97% rename from helper-install/stat.sh rename to helper_install/stat.sh index f13f3b2..fbec517 100755 --- a/helper-install/stat.sh +++ b/helper_install/stat.sh @@ -1,11 +1,19 @@ #!/usr/bin/env bash function stat() { + if [ "${2}" == "Success" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_SUCCESS}${3}${COLOR_BASED}" + elif [ "${2}" == "Warning" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_WARNING}${3}${COLOR_BASED}" + elif [ "${3}" == "Danger" ]; then + echo -e " [ ${COLOR_WARNING}${1}${COLOR_BASED} ] > ${COLOR_DANGER}${3}${COLOR_BASED}" + fi + } \ No newline at end of file diff --git a/helper-install/switchcase.sh b/helper_install/switchcase.sh similarity index 100% rename from helper-install/switchcase.sh rename to helper_install/switchcase.sh diff --git a/helper-install/themes.sh b/helper_install/themes.sh similarity index 100% rename from helper-install/themes.sh rename to helper_install/themes.sh diff --git a/helper-install/utility.sh b/helper_install/utility.sh similarity index 100% rename from helper-install/utility.sh rename to helper_install/utility.sh diff --git a/install.sh b/install.sh index 4e0a3b5..dc37d88 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ HELPERS=( ) for HELPER in ${HELPERS[@]}; do - source $(pwd)/helper-install/${HELPER}.sh + source $(pwd)/helper_install/${HELPER}.sh done # # Done From 85c94e491871817579488bfe6d7f50cf4854c484 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:08:40 +0700 Subject: [PATCH 03/10] Change structure code installation with Human Readable xD --- .functions.sh | 514 ----------------------------------- .variables.sh | 74 ----- helper_install/animation.sh | 2 +- helper_install/screen.sh | 30 -- helper_install/switchcase.sh | 133 +-------- install.sh | 42 +-- 6 files changed, 30 insertions(+), 765 deletions(-) delete mode 100755 .functions.sh delete mode 100644 .variables.sh delete mode 100755 helper_install/screen.sh diff --git a/.functions.sh b/.functions.sh deleted file mode 100755 index 6681959..0000000 --- a/.functions.sh +++ /dev/null @@ -1,514 +0,0 @@ -#!/usr/bin/env bash - -source $(pwd)/.variables.sh -source $(pwd)/.animation/ghost.sh - -function logDate() { - echo -e " [${COLOR_WARNING}$(date +'%A, %d %B %Y %r')${COLOR_BASED}] > $@" -} - -function banner() { - echo -e "\n${COLOR_SKY} - ╭────────────────────────────────────────────────────────────────╮ - ┃ ${COLOR_DANGER}_______${COLOR_SKY} ┃ - ┃ ${COLOR_DANGER}(_______)${COLOR_SKY} ┃ - ┃ ${COLOR_BASED}____ _ _ ${COLOR_DANGER}_${COLOR_BASED} _____ ____ ____ _ _ _ _ ${COLOR_SKY}┃ - ┃ ${COLOR_BASED}| \| | | ${COLOR_DANGER}| |${COLOR_BASED} ___ |/ ___) \| | | ( \ / ) ${COLOR_SKY}┃ - ┃ ${COLOR_BASED}| | | | |_| ${COLOR_DANGER}| |${COLOR_BASED} ____| | | | | | |_| |) X ( ${COLOR_SKY}┃ - ┃ ${COLOR_BASED}|_|_|_|\__ ${COLOR_DANGER}|_|${COLOR_BASED}_____)_| |_|_|_|____/(_/ \_) ${COLOR_SKY}┃ - ┃ ${COLOR_BASED}(____/ ${COLOR_SKY}┃ - ┃ ┃ - ┃ ${COLOR_BASED}🚀 Version : ${VERSION} ${COLOR_SKY} ┃ - ┃ ${COLOR_BASED}📅 Build Date : ${BUILD_DATE} ${COLOR_SKY}┃ - ┃ ${COLOR_BASED}⚙️ Author : ${AUTHOR} ${COLOR_SKY}┃ - ┃ ┃ - ╰────────────────────────────────────────────────────────────────╯${COLOR_BASED}" -} - -function informationPackages() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Packages" - echo -e " - ╭─────────────────────────────────────────────────────────────────────────────────────╮ - ┃ Information Packages ┃ - ╰─────────────────────────────────────────────────────────────────────────────────────╯ - ┃ Package Name ┃ Version ┃ Download ┃ Installed ┃ - ╰─────────────────────────────────────────────────────────────────────────────────────╯" - - for DEPENDENCY_PACKAGE in "${DEPENDENCY_PACKAGES[@]}"; do - - PACKAGE_NAME=$(apt show $DEPENDENCY_PACKAGE 2> /dev/null | grep Package: | awk '{print $2}') - VERSION=$(apt show $DEPENDENCY_PACKAGE 2> /dev/null | grep Version: | awk '{print $2}') - DOWNLOAD_SIZE=$(apt show $DEPENDENCY_PACKAGE 2> /dev/null | grep Download-Size: | awk '{print $2$3}') - INSTALLED_SIZE=$(apt show $DEPENDENCY_PACKAGE 2> /dev/null | grep Installed-Size: | awk '{print $2$3}') - printf " ┃ %-13s ▎ %10s ▎ %6s ▎ %6s ┃\n" $PACKAGE_NAME $VERSION $DOWNLOAD_SIZE $INSTALLED_SIZE - - done - - echo -e " ╰─────────────────────────────────────────────────────────────────────────────────────╯ - " - - read -p " Do you want to install the packages? [Y/n] " Ask - - case "$Ask" in - - "" ) - installDependencyPackages - ;; - - y|Y ) - installDependencyPackages - ;; - - n|N ) - logDate Status Installation [${COLOR_WARNING}Abort.${COLOR_BASED}] - echo "" - exit 1 - ;; - - * ) - logDate [${COLOR_DANGER}ERROR ANSWER${COLOR_BASED}] - exit 1 - ;; - - esac - -} - -function installDependencyPackages() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Downloading Package\n" - echo -e "Downloading Package:" >> $(pwd)/.log - - for DEPENDENCY_PACKAGE in "${DEPENDENCY_PACKAGES[@]}"; do - - start_ghost " Installing ${DEPENDENCY_PACKAGE}..." - - pkg i -y $DEPENDENCY_PACKAGE &>/dev/null - THIS_PACKAGE=$(pkg list-installed $DEPENDENCY_PACKAGE 2> /dev/null | tail -n 1) - CHECK_PACKAGE=${THIS_PACKAGE%/*} - - if [[ $CHECK_PACKAGE == $DEPENDENCY_PACKAGE ]]; then - - stop_ghost $? || exit 1 - echo -e "$(date +'%A, %d %B %Y %r') Status $DEPENDENCY_PACKAGE [SUCCESS]" >> $(pwd)/.log - - else - - stop_ghost $? - echo -e "$(date +'%A, %d %B %Y %r') Status $DEPENDENCY_PACKAGE [FAILED]" >> $(pwd)/.log - - fi - - done - - echo -e "" >> $(pwd)/.log - -} - -function changeSHELL() { - chsh -s zsh -} - -function OhMyZSH() { - - logDate Installing ${REPOSITORY_LINKS[0]} - - git clone git://github.com/${REPOSITORY_LINKS[0]} ${REPOSITORY_PATH[0]} &>/dev/null - - if [ -d ${REPOSITORY_PATH[0]} ]; then - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - - else - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_DANGER}FAILED${COLOR_BASED}] - - fi - -} - -function pluginZSHHighlighting() { - - logDate Installing ${REPOSITORY_LINKS[1]} - - git clone git://github.com/${REPOSITORY_LINKS[1]} ${REPOSITORY_PATH[1]} &>/dev/null - - if [ -d ${REPOSITORY_PATH[1]} ]; then - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - - else - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_DANGER}FAILED${COLOR_BASED}] - - fi - -} - -function pluginZSHAutosuggestion() { - - logDate Installing ${REPOSITORY_LINKS[2]} - git clone git://github.com/${REPOSITORY_LINKS[2]} ${REPOSITORY_PATH[2]} &>/dev/null - - if [ -d ${REPOSITORY_PATH[2]} ]; then - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - - else - - logDate Status ${REPOSITORY_LINKS[0]} [${COLOR_DANGER}FAILED${COLOR_BASED}] - - fi - -} - -function repoSize() { - - echo "$(echo "scale=2 - $(curl https://api.github.com/$@ 2>/dev/null | grep size | head -1 | tr -dc '[:digit:]') / 1024" | bc)MB" - -} - -function informationRepository() { - - sed -i 's/ICON="•"/ICON=" "/g' .animation/ghost.sh - source .animation/ghost.sh - - echo -e "‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Repository" - sleep 2s - - echo -e " - ╭────────────────────────────────────────────────────────────────────╮ - ┃ Information Repository ┃ - ╰────────────────────────────────────────────────────────────────────╯ - ┃ Repository Name ┃ Repository Size ┃ - ╰────────────────────────────────────────────────────────────────────╯" - - for REPOSITORY_API in "${REPOSITORY_APIS[@]}"; do - - REPOSITORY_NAME=$(curl https://api.github.com/${REPOSITORY_API} 2> /dev/null | grep full_name | awk '{print $2}' | sed "s/,//g" | sed "s/\"//g") - printf " ┃ %-36s ▎ %8s ┃\n" $REPOSITORY_NAME `repoSize $REPOSITORY_API` - - done - - echo " ╰────────────────────────────────────────────────────────────────────╯" -} - -function cloneRepository() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Cloning or Downloading Repository\n" - echo -e "Cloning or Downloading Repository:" >> $(pwd)/.log - sleep 2s - - for ((i=0; i<${#REPOSITORY_LINKS[@]}; i++)); do - - start_ghost " Installing ${REPOSITORY_FULL_NAME[i]}..." - - git clone ${REPOSITORY_LINKS[i]} ${REPOSITORY_PATH[i]} 2> /dev/null - - if [ -d ${REPOSITORY_PATH[i]} ]; then - - stop_ghost $? || exit 1 - # logDate Status ${REPOSITORY_LINKS[i]} [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - echo -e "$(date +'%A, %d %B %Y %r') Status ${REPOSITORY_LINKS[i]} [SUCCESS]" >> $(pwd)/.log - sleep 2s - # logDate Repository PATH ${REPOSITORY_PATH[i]} - - else - - stop_ghost $? - echo -e "$(date +'%A, %d %B %Y %r') Status ${REPOSITORY_LINKS[i]} [FAILED]" >> $(pwd)/.log - - fi - - done - - echo -e "" >> $(pwd)/.log - -} - -function dotFiles() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Getting Information Dotfiles" - sleep 2s - - echo -e " - ╭───────────────────────────────────────────────╮ - ┃ Information Dotfiles ┃ - ╰───────────────────────────────────────────────╯ - ┃ Folder Name ┃ Folder Size ┃ - ╰───────────────────────────────────────────────╯" - - for DOTFILE in "${DOTFILES[@]}"; do - - FOLDER_SIZE=$(du -s -h $DOTFILE | awk '{print $1}') - printf " ┃ %-12s ▎ %5s ┃\n" $DOTFILE $FOLDER_SIZE - - done - - echo " ╰───────────────────────────────────────────────╯" - -} - -function backupDotFiles() { - - function backupExec() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Backup dotfiles" - echo -e "Backup dotfile:" >> $(pwd)/.log - echo -e "" - sleep 2s - - for BACKUP_DOTFILE in "${BACKUP_DOTFILES[@]}"; do - - start_ghost " Backup ${BACKUP_DOTFILE}..." - sleep 2s - - if [[ -d "$HOME/$BACKUP_DOTFILE" || -f "$HOME/$BACKUP_DOTFILE" ]]; then - - mv ${HOME}/${BACKUP_DOTFILE} ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S); - - if [[ -d ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S) || -f ${HOME}/${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S) ]]; then - - # logDate Status $BACKUP_DOTFILE to ${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S)] - stop_ghost $? || exit 1 - echo -e "$(date +'%A, %d %B %Y %r') Status $BACKUP_DOTFILE to ${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S) [SUCCESS]" >> $(pwd)/.log - # echo -e "" - - else - - stop_ghost $? - # logDate Status $BACKUP_DOTFILE to ${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S) [${COLOR_DANGER}FAILED${COLOR_BASED}] - echo -e "$(date +'%A, %d %B %Y %r') Status $BACKUP_DOTFILE to ${BACKUP_DOTFILE}.$(date +%Y.%m.%d-%H.%M.%S) [FAILED]" >> $(pwd)/.log - # echo -e "" - - fi - - else - - # logDate Status $BACKUP_DOTFILE [${COLOR_WARNING}NOT FOUND${COLOR_BASED}] - stop_ghost $? - echo -e "$(date +'%A, %d %B %Y %r') Status $BACKUP_DOTFILE [NOT FOUND]" >> $(pwd)/.log - # echo -e "" - - fi - - done - echo -e "" >> $(pwd)/.log - - } - - backupExec - installDotFiles - -} - -function installDotFiles() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing Dotfiles\n" - echo -e "Installing dotfile:" >> $(pwd)/.log - - for DOTFILE in "${DOTFILES[@]}"; do - - # logDate Installing $DOTFILE ... - start_ghost " Installing ${DOTFILE}..." - cp -R $DOTFILE $HOME - - if [[ -d $HOME/$DOTFILE || -f $HOME/$DOTFILE ]]; then - - # logDate Status $DOTFILE [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - stop_ghost $? || exit 1 - echo -e "$(date +'%A, %d %B %Y %r') Status $DOTFILE [SUCCESS]" >> $(pwd)/.log - - else - - # logDate Status $DOTFILE [${COLOR_DANGER}FAILED${COLOR_BASED}] - stop_ghost $? - echo -e "$(date +'%A, %d %B %Y %r') Status $DOTFILE [FAILED]" >> $(pwd)/.log - - fi - - # echo -e "" - - done - - echo -e "" - echo -e "" >> $(pwd)/.log - -} - -function neovimPlugins() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing Neovim Plugins with Packer\n" - echo -e "Installing Neovim Plugins:" >> $(pwd)/.log - - if [ -d $HOME/NvChad ]; then - - logDate Status NvChad [${COLOR_SUCCESS}FOUND${COLOR_BASED}] - - logDate Move NvChad to .config/nvim - mv $HOME/NvChad $HOME/.config/nvim - if [ -d $HOME/.config/nvim ]; then - - logDate Status .config/nvim [${COLOR_SUCCESS}OK${COLOR_BASED}] - - logDate Status Installer [${COLOR_SUCCESS}READY${COLOR_BASED}] - nvim +'hi NormalFloat guibg=#1e222a' +PackerSync - logDate Status Neovim Plugins [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - echo -e "$(date +'%A, %d %B %Y %r') Status Neovim Plugins [SUCCESS]" >> $(pwd)/.log - - else - - logDate Status .config/nvim [${COLOR_DANGER}Configuration not found${COLOR_BASED}] - echo -e "$(date +'%A, %d %B %Y %r') Status .config/nvim [Configuration not found]" >> $(pwd)/.log - - fi - - else - - logDate Status NvChad [${COLOR_DANGER}NvChad not found${COLOR_BASED}] - echo -e "$(date +'%A, %d %B %Y %r') Status NvChad [NvChad not found]" >> $(pwd)/.log - - fi - - # if [ -f $HOME/NvChad/install.sh ]; then - - # bash $HOME/NvChad/install.sh -i - # logDate Status Neovim Plugins [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - # cp $(pwd)/neovim-settings/xshin.lua $HOME/.config/nvim/lua/xshin.lua - # sed -i 's/"mappings"/"mappings",/g' ~/.config/nvim/init.lua - # sed -i '4i\ "xshin"' ~/.config/nvim/init.lua - # sed -i 's/g.nvim_tree_hide_dotfiles = 1/g.nvim_tree_hide_dotfiles = 0/g' ~/.config/nvim/lua/plugins/nvimtree.lua - # echo -e "$(date +'%A, %d %B %Y %r') Status Neovim Plugins [SUCCESS]" >> $(pwd)/.log - - # else - - # logDate Status [${COLOR_DANGER}ERROR INSTALLER NOT FOUND${COLOR_BASED}] - # echo -e "$(date +'%A, %d %B %Y %r') Status Neovim Plugins [ERROR INSTALLER NOT FOUND]" >> $(pwd)/.log - - - # fi - - echo -e "" >> $(pwd)/.log - -} - -function zshThemes() { - - echo -e "\n‏‏‎‏‏‎ ‎ ‎‏‏‎ ‎📦 Installing ZSH Custom Themes\n" - echo -e "Installing ZSH Custom Themes:" >> $(pwd)/.log - - PATHDIR=".oh-my-zsh/custom/themes" - - for ZSH_CUSTOM_THEME in "${ZSH_CUSTOM_THEMES[@]}"; do - - # logDate $ZSH_CUSTOM_THEME - start_ghost " Installing ${ZSH_CUSTOM_THEME}..." - sleep 2s - cp $(pwd)/${PATHDIR}/${ZSH_CUSTOM_THEME} $HOME/${PATHDIR}/${ZSH_CUSTOM_THEME} - - if [ -f $HOME/$PATHDIR/$ZSH_CUSTOM_THEME ]; then - - # logDate Status $ZSH_CUSTOM_THEME [${COLOR_SUCCESS}SUCCESS${COLOR_BASED}] - stop_ghost $? || exit 1 - echo -e "$(date +'%A, %d %B %Y %r') Status $ZSH_CUSTOM_THEME [SUCCESS]" >> $(pwd)/.log - - else - - # logDate Status $ZSH_CUSTOM_THEME [${COLOR_DANGER}FAILED${COLOR_BASED}] - stop_ghost $? - echo -e "$(date +'%A, %d %B %Y %r') Status $ZSH_CUSTOM_THEME [FAILED]" >> $(pwd)/.log - - fi - - # echo -e "" - - done - - echo -e "" - echo -e "" >> $(pwd)/.log - -} - -function reloadSettings() { - $(termux-reload-settings) -} - -function welcomeTermux() { - - if [[ -f $PREFIX/etc/motd ]]; then - - mkdir tmp - mv $PREFIX/etc/motd $(pwd)/tmp/motd.backup - - fi - -} - -function alert() { - - echo -e "‏‏‎‏‏‎ ‎‏‏‎ ⚠️ Log saved on $(pwd)/.log\n" - echo -e "‏‏‎‏‏‎ ‎‏‏‎ ⚠️ Installation Finish, but you need restart Termux to clear setup\n" - -} - -function awesomeshotFont() { - cp ~/.termux/fonts/NerdFonts/JetBrains/JetBrains\ Mono\ Medium\ Nerd\ Font\ Complete.ttf $PREFIX/share/fonts/TTF/ 2> /dev/null -} - -function execute() { - - clear - banner - informationPackages - dotFiles - backupDotFiles - reloadSettings - awesomeshotFont - informationRepository - cloneRepository - neovimPlugins - zshThemes - changeSHELL - welcomeTermux - alert - -} - -function screenSize() { - - if [[ -n ${COLS} && -n ${ROWS} ]]; then - - if (( ${COLS} == 101 && ${ROWS} == 42 )); then - - execute - - elif (( ${COLS} >= 101 & ${ROWS} >= 42 )); then - - execute - - elif (( ${COLS} <= 101 & ${ROWS} <= 42 )); then - - echo -e "[${COLOR_DANGER} ERROR ${COLOR_BASED}] > Please ${COLOR_WARNING}zoom out${COLOR_BASED} your terminal screen" - - - else - - echo -e "[${COLOR_DANGER} ABORT ${COLOR_BASED}] > Unknown ${COLOR_WARNING}Error${COLOR_BASED}" - - fi - - else - - echo -e "[${COLOR_DANGER} ERROR ${COLOR_BASED}] > Please run '${COLOR_WARNING}export COLUMNS LINES${COLOR_BASED}'" - - fi - -} - -function main() { - - screenSize - -} diff --git a/.variables.sh b/.variables.sh deleted file mode 100644 index 79db6f8..0000000 --- a/.variables.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -#/data/data/com.termux/files/usr/bin/env bash - -COLOR_BASED="\e[39m" -COLOR_DANGER="\e[91m" -COLOR_WARNING="\e[93m" -COLOR_SUCCESS="\e[92m" -COLOR_SKY="\e[34m" - -VERSION="0.5.1" -BUILD_DATE="05 October 2021" -AUTHOR="xShin" - -COLS=$(echo $COLUMNS) -ROWS=$(echo $LINES) - -DEPENDENCY_PACKAGES=( - bat curl clang exa git imagemagick - inotify-tools lf mpd mpc neovim - neofetch termux-api tmux zsh -) - -DOTFILES=( - .local .config .termux .color-toys .scripts - .zshrc .tmux.conf .autostart .aliases -) - -BACKUP_DOTFILES=( - .autostart .aliases - .local .config .termux - .color-toys .scripts .zshrc - .tmux.conf .oh-my-zsh -) - -REPOSITORY_LINKS=( - https://github.com/robbyrussell/oh-my-zsh - https://github.com/zsh-users/zsh-syntax-highlighting - https://github.com/zsh-users/zsh-autosuggestions - https://github.com/jimeh/tmux-themepack - https://github.com/NvChad/NvChad -) - -REPOSITORY_APIS=( - repositories/291137 - repos/zsh-users/zsh-syntax-highlighting - repos/zsh-users/zsh-autosuggestions - repos/jimeh/tmux-themepack - repos/NvChad/NvChad -) - -REPOSITORY_FULL_NAME=( - robbyrussell/oh-my-zsh - zsh-users/zsh-syntax-highlighting - zsh-users/zsh-autosuggestions - jimeh/tmux-themepack - siduck76/NvChad -) - -REPOSITORY_PATH=( - $HOME/.oh-my-zsh/ - $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting - $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions - $HOME/.tmux-themepack - $HOME/NvChad -) - -ZSH_CUSTOM_THEMES=( - osx.zsh-theme - archcraft.zsh-theme - ar-round.zsh-theme - la-round.zsh-theme - rounded-custom.zsh-theme - rounded.zsh-theme -) diff --git a/helper_install/animation.sh b/helper_install/animation.sh index 473a012..82a054c 100755 --- a/helper_install/animation.sh +++ b/helper_install/animation.sh @@ -70,7 +70,7 @@ function animation() { kill ${3} > /dev/null 2>&1 - echo -en "\b${COLOR_DEFAULT}> [" + echo -en "\b${COLOR_DEFAULT} --> [" if [[ $2 -eq 0 ]]; then echo -en " ${COLOR_GREEN}${OK}${COLOR_DEFAULT} " diff --git a/helper_install/screen.sh b/helper_install/screen.sh deleted file mode 100755 index b4e3e68..0000000 --- a/helper_install/screen.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -COLS=$(echo $COLUMNS) -ROWS=$(echo $LINES) - -function screenSize() { - - if [[ -n ${COLS} && -n ${ROWS} ]]; then - - if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then - - ${1} - - elif (( ${COLS} <= 101 & ${ROWS} <= 42 )); then - - stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" - - else - - stat "ERROR" "Danger" "Unknown ERROR!!!" - - fi - - else - - stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" - - fi - -} \ No newline at end of file diff --git a/helper_install/switchcase.sh b/helper_install/switchcase.sh index 5cc07da..3feda41 100755 --- a/helper_install/switchcase.sh +++ b/helper_install/switchcase.sh @@ -17,139 +17,14 @@ function switchCase() { ;; n|N ) - echo -e "Nnaaahh" - + stat "ERROR" "Warning" "Abort." ;; * ) - echo -e "ERROR" + stat "ERROR" "Warning" "Unknown '${SWITCH_CASE}'" + switchCase ${1} ${2} ${3} ;; esac -} - -function caseInstallPackage() { - - read -p " Do you want to install the packages? [Y/n] " INSTALL_PACKAGES - - case "$INSTALL_PACKAGES" in - - "" ) - installPackages - ;; - - y|Y ) - installPackages - ;; - - n|N ) - echo -e "No" - ;; - - * ) - echo -e "Unknown" - ;; - - esac - -} - -function caseBackupDotFiles() { - - read -p " Do you want to backup the dotfiles? [Y/n] " BACKUP_DOTFILES - - if [ "${BACKUP_DOTFILES}" == "" ]; then - - backupDotFiles - - elif [ "${BACKUP_DOTFILES}" == "y" ]; then - - backupDotFiles - - else - - exit - - fi - -} - -function caseInstallDotfiles() { - - read -p " Do you want to install dotfiles? [Y/n] " INSTALL_DOTFILES - - case "$INSTALL_DOTFILES" in - - "" ) - installDotFiles - ;; - - y|Y ) - installDotFiles - ;; - - n|N ) - echo -e "No" - ;; - - * ) - echo -e "Unknown" - ;; - - esac - -} - -function caseCloneRepository() { - - read -p " Do you want to clone repository? [Y/n] " CLONE_REPOSITORY - - case "$CLONE_REPOSITORY" in - - "" ) - cloneRepository - ;; - - y|Y ) - cloneRepository - ;; - - n|N ) - echo -e "No" - ;; - - * ) - echo -e "Unknown" - ;; - - esac - -} - -function caseInstallZshTheme() { - - read -p " Do you want to install ZSH Theme? [Y/n] " INSTALL_ZSH_THEME - - case "$INSTALL_ZSH_THEME" in - - "" ) - installZshTheme - ;; - - y|Y ) - installZshTheme - ;; - - n|N ) - echo -e "No" - ;; - - * ) - echo -e "Unknown" - ;; - - esac - -} - +} \ No newline at end of file diff --git a/install.sh b/install.sh index dc37d88..dc67b29 100755 --- a/install.sh +++ b/install.sh @@ -3,39 +3,47 @@ HELPERS=( colors animation banner package switchcase dotfiles clone themes nvchad utility - stat signal screen cursor finish + stat signal cursor finish ) for HELPER in ${HELPERS[@]}; do source $(pwd)/helper_install/${HELPER}.sh done -# # Done -# banner -# packages -# caseInstallPackage -# dotFiles +COLS=$(echo $COLUMNS) +ROWS=$(echo $LINES) -# # Error Array -# #caseBackupDotFiles +function screenSize() { -# # Done -# backupDotFiles -# caseInstallDotfiles + if [[ -n ${COLS} && -n ${ROWS} ]]; then -# cloneRepositories -# caseCloneRepository + if (( ${COLS} >= 101 && ${ROWS} >= 39 )); then -# zshTheme -# caseInstallZshTheme + ${1} -# NvChad -# utility + elif (( ${COLS} <= 101 && ${ROWS} <= 39 )); then + + stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" + + else + + stat "ERROR" "Danger" "Unknown ERROR!!!" + + fi + + else + + stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" + + fi + +} function main() { trap 'handleInterruptByUser "Interrupt by User"' 2 + clear banner packages From a34ecdb896dc5cde8a286598b6672edc688291b9 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:09:58 +0700 Subject: [PATCH 04/10] Change structure code installation with Human Readable xD --- helper_install/animation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper_install/animation.sh b/helper_install/animation.sh index 82a054c..e3fc57c 100755 --- a/helper_install/animation.sh +++ b/helper_install/animation.sh @@ -70,7 +70,7 @@ function animation() { kill ${3} > /dev/null 2>&1 - echo -en "\b${COLOR_DEFAULT} --> [" + echo -en "\b${COLOR_DEFAULT} ──> [" if [[ $2 -eq 0 ]]; then echo -en " ${COLOR_GREEN}${OK}${COLOR_DEFAULT} " From 71917c807b66204370ee2ba827f3e6ef8a80e7e1 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:12:39 +0700 Subject: [PATCH 05/10] Change structure code installation with Human Readable xD --- helper_install/dotfiles.sh | 2 +- install.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helper_install/dotfiles.sh b/helper_install/dotfiles.sh index 35ac013..f712a8d 100755 --- a/helper_install/dotfiles.sh +++ b/helper_install/dotfiles.sh @@ -50,7 +50,7 @@ function backupDotFiles() { for BACKUP_DOTFILE in "${BACKUP_DOTFILES[@]}"; do - start_animation " Backup ${COLOR_SUCCESS}${BACKUP_DOTFILE}${COLOR_BASED} ..." + start_animation " Backup ${COLOR_WARNING}'${COLOR_SUCCESS}${BACKUP_DOTFILE}${COLOR_WARNING}'${COLOR_BASED} ..." sleep 1s if [[ -d "$HOME/$BACKUP_DOTFILE" || -f "$HOME/$BACKUP_DOTFILE" ]]; then diff --git a/install.sh b/install.sh index dc67b29..b3f8b6c 100755 --- a/install.sh +++ b/install.sh @@ -62,6 +62,8 @@ function main() { NvChad utility + alertFinish + } screenSize main \ No newline at end of file From 42fe1e70bc5313eb86d26ff154c2ebc87850fa99 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:16:34 +0700 Subject: [PATCH 06/10] Change structure code installation with Human Readable xD --- {helper_install => helper}/animation.sh | 0 {helper_install => helper}/banner.sh | 0 {helper_install => helper}/clone.sh | 0 {helper_install => helper}/colors.sh | 0 {helper_install => helper}/cursor.sh | 0 {helper_install => helper}/dotfiles.sh | 0 {helper_install => helper}/finish.sh | 0 {helper_install => helper}/nvchad.sh | 0 {helper_install => helper}/package.sh | 0 {helper_install => helper}/signal.sh | 0 {helper_install => helper}/stat.sh | 0 {helper_install => helper}/switchcase.sh | 0 {helper_install => helper}/themes.sh | 0 {helper_install => helper}/utility.sh | 0 install.sh | 2 +- 15 files changed, 1 insertion(+), 1 deletion(-) rename {helper_install => helper}/animation.sh (100%) rename {helper_install => helper}/banner.sh (100%) rename {helper_install => helper}/clone.sh (100%) rename {helper_install => helper}/colors.sh (100%) rename {helper_install => helper}/cursor.sh (100%) rename {helper_install => helper}/dotfiles.sh (100%) rename {helper_install => helper}/finish.sh (100%) rename {helper_install => helper}/nvchad.sh (100%) rename {helper_install => helper}/package.sh (100%) rename {helper_install => helper}/signal.sh (100%) rename {helper_install => helper}/stat.sh (100%) rename {helper_install => helper}/switchcase.sh (100%) rename {helper_install => helper}/themes.sh (100%) rename {helper_install => helper}/utility.sh (100%) diff --git a/helper_install/animation.sh b/helper/animation.sh similarity index 100% rename from helper_install/animation.sh rename to helper/animation.sh diff --git a/helper_install/banner.sh b/helper/banner.sh similarity index 100% rename from helper_install/banner.sh rename to helper/banner.sh diff --git a/helper_install/clone.sh b/helper/clone.sh similarity index 100% rename from helper_install/clone.sh rename to helper/clone.sh diff --git a/helper_install/colors.sh b/helper/colors.sh similarity index 100% rename from helper_install/colors.sh rename to helper/colors.sh diff --git a/helper_install/cursor.sh b/helper/cursor.sh similarity index 100% rename from helper_install/cursor.sh rename to helper/cursor.sh diff --git a/helper_install/dotfiles.sh b/helper/dotfiles.sh similarity index 100% rename from helper_install/dotfiles.sh rename to helper/dotfiles.sh diff --git a/helper_install/finish.sh b/helper/finish.sh similarity index 100% rename from helper_install/finish.sh rename to helper/finish.sh diff --git a/helper_install/nvchad.sh b/helper/nvchad.sh similarity index 100% rename from helper_install/nvchad.sh rename to helper/nvchad.sh diff --git a/helper_install/package.sh b/helper/package.sh similarity index 100% rename from helper_install/package.sh rename to helper/package.sh diff --git a/helper_install/signal.sh b/helper/signal.sh similarity index 100% rename from helper_install/signal.sh rename to helper/signal.sh diff --git a/helper_install/stat.sh b/helper/stat.sh similarity index 100% rename from helper_install/stat.sh rename to helper/stat.sh diff --git a/helper_install/switchcase.sh b/helper/switchcase.sh similarity index 100% rename from helper_install/switchcase.sh rename to helper/switchcase.sh diff --git a/helper_install/themes.sh b/helper/themes.sh similarity index 100% rename from helper_install/themes.sh rename to helper/themes.sh diff --git a/helper_install/utility.sh b/helper/utility.sh similarity index 100% rename from helper_install/utility.sh rename to helper/utility.sh diff --git a/install.sh b/install.sh index b3f8b6c..b946afc 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ HELPERS=( ) for HELPER in ${HELPERS[@]}; do - source $(pwd)/helper_install/${HELPER}.sh + source $(pwd)/helper/${HELPER}.sh done COLS=$(echo $COLUMNS) From 28e85e9b87380dc8188712b0bc67405be7eb8147 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:23:53 +0700 Subject: [PATCH 07/10] Change structure code installation with Human Readable xD --- install.sh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index b946afc..dd70aff 100755 --- a/install.sh +++ b/install.sh @@ -10,31 +10,28 @@ for HELPER in ${HELPERS[@]}; do source $(pwd)/helper/${HELPER}.sh done -COLS=$(echo $COLUMNS) -ROWS=$(echo $LINES) function screenSize() { + + COLS=$(echo $COLUMNS) + ROWS=$(echo $LINES) if [[ -n ${COLS} && -n ${ROWS} ]]; then - - if (( ${COLS} >= 101 && ${ROWS} >= 39 )); then + + if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then ${1} - - elif (( ${COLS} <= 101 && ${ROWS} <= 39 )); then - - stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" - + else - stat "ERROR" "Danger" "Unknown ERROR!!!" + stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" fi else stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" - + fi } From fbddf6286eda15753436aeb7c62f0fea5ba7b90a Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:25:56 +0700 Subject: [PATCH 08/10] Change structure code installation with Human Readable xD --- install.sh | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index dd70aff..c4c42ce 100755 --- a/install.sh +++ b/install.sh @@ -10,32 +10,6 @@ for HELPER in ${HELPERS[@]}; do source $(pwd)/helper/${HELPER}.sh done - -function screenSize() { - - COLS=$(echo $COLUMNS) - ROWS=$(echo $LINES) - - if [[ -n ${COLS} && -n ${ROWS} ]]; then - - if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then - - ${1} - - else - - stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" - - fi - - else - - stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" - - fi - -} - function main() { trap 'handleInterruptByUser "Interrupt by User"' 2 @@ -63,4 +37,23 @@ function main() { } -screenSize main \ No newline at end of file +COLS=$(echo $COLUMNS) +ROWS=$(echo $LINES) + +if [[ -n ${COLS} && -n ${ROWS} ]]; then + + if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then + + main + + else + + stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" + + fi + +else + + stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" + +fi \ No newline at end of file From aad8c06d1720a08014b519da8699dc9c75f6a5d8 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:32:46 +0700 Subject: [PATCH 09/10] Change structure code installation with Human Readable xD --- helper/screen.sh | 26 ++++++++++++++++++++++++++ install.sh | 23 ++--------------------- 2 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 helper/screen.sh diff --git a/helper/screen.sh b/helper/screen.sh new file mode 100644 index 0000000..27a732e --- /dev/null +++ b/helper/screen.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +function screenSize() { + + COLS=$(echo $COLUMNS) + ROWS=$(echo $LINES) + + if [[ -n ${COLS} && -n ${ROWS} ]]; then + + if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then + + ${1} + + else + + echo -e "[ ${COLOR_WARNING}ERROR${COLOR_BASED} ] > Please ${COLOR_WARNING}zoom out${COLOR_BASED} your Terminal Screen!" + + fi + + else + + echo -e "[ ${COLOR_WARNING}ERROR${COLOR_BASED} ] > Please run '${COLOR_WARNING}export COLUMNS LINES${COLOR_BASED}' first and then run again!" + + fi + +} \ No newline at end of file diff --git a/install.sh b/install.sh index c4c42ce..9888615 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,7 @@ HELPERS=( colors animation banner package switchcase dotfiles clone themes nvchad utility - stat signal cursor finish + stat signal screen cursor finish ) for HELPER in ${HELPERS[@]}; do @@ -37,23 +37,4 @@ function main() { } -COLS=$(echo $COLUMNS) -ROWS=$(echo $LINES) - -if [[ -n ${COLS} && -n ${ROWS} ]]; then - - if (( ${COLS} >= 101 & ${ROWS} >= 39 )); then - - main - - else - - stat "ERROR" "Warning" "Please zoom out your Terminal Screen!" - - fi - -else - - stat "ERROR" "Danger" "Please run 'export COLUMNS LINES' first and then run again!" - -fi \ No newline at end of file +screenSize main \ No newline at end of file From c426754666f8f7a957aa5d96f96e737b74fc4447 Mon Sep 17 00:00:00 2001 From: xshin404 Date: Tue, 19 Oct 2021 23:36:07 +0700 Subject: [PATCH 10/10] Change structure code installation with Human Readable xD --- helper/screen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/screen.sh b/helper/screen.sh index 27a732e..3f92172 100644 --- a/helper/screen.sh +++ b/helper/screen.sh @@ -19,7 +19,7 @@ function screenSize() { else - echo -e "[ ${COLOR_WARNING}ERROR${COLOR_BASED} ] > Please run '${COLOR_WARNING}export COLUMNS LINES${COLOR_BASED}' first and then run again!" + echo -e "[ ${COLOR_DANGER}ERROR${COLOR_BASED} ] > Please run '${COLOR_WARNING}export COLUMNS LINES${COLOR_BASED}' first and then run again!" fi