Browse Source

install: tweaks, format and option for development branch

my-config
NTBBloodbath 4 years ago
parent
commit
5774b1c1e7
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 383
      install.sh

383
install.sh

@ -11,33 +11,31 @@
Color_reset='\033[0m' # Reset
## Normal colors
Black='\033[0;30m' # Black
White='\033[0;37m' # White
Red='\033[0;31m' # Red
Blue='\033[0;34m' # Blue
Cyan='\033[0;36m' # Cyan
Purple='\033[0;35m' # Purple
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Black='\033[0;30m' # Black
White='\033[0;37m' # White
Red='\033[0;31m' # Red
Blue='\033[0;34m' # Blue
Cyan='\033[0;36m' # Cyan
Purple='\033[0;35m' # Purple
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
## Bold colors
BBlack='\033[1;30m' # Black
BWhite='\033[1;37m' # White
BRed='\033[1;31m' # Red
BBlue='\033[1;34m' # Blue
BCyan='\033[1;36m' # Cyan
BPurple='\033[1;35m' # Purple
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
BBlack='\033[1;30m' # Black
BWhite='\033[1;37m' # White
BRed='\033[1;31m' # Red
BBlue='\033[1;34m' # Blue
BCyan='\033[1;36m' # Cyan
BPurple='\033[1;35m' # Purple
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
# }}}
# Doom Nvim version
DoomNvimVersion='1.2.0'
DoomNvimVersion='1.2.1'
# System OS
System="$(uname -s)"
# Terminal Output
# ===============
# {{{
@ -54,82 +52,74 @@ log_info() {
}
log_error() {
log "${Red}[X]${Color_reset} ${1}${2}"
log "${Red}[×]${Color_reset} ${1}${2}"
exit 1
}
log_warn () {
log_warn() {
log "${Yellow}[!]${Color_reset} ${1}${2}"
}
pretty_echo () {
pretty_echo() {
printf '%b\n' "$1$2$Color_reset" >&2
}
# }}}
# Check requirements
# ==================
# {{{
need_cmd() {
if ! hash "$1" &> /dev/null; then
if ! hash "$1" &>/dev/null; then
log_error "Need '$1' (command not found)"
exit 1
fi
}
check_cmd() {
if ! type "$1" &> /dev/null; then
log_warn "Need '$1' (command not found)"
fi
if ! type "$1" &>/dev/null; then
log_warn "Need '$1' (command not found)"
fi
}
check_all() {
# Install Doom Nvim (see also git)
need_cmd 'curl'
need_cmd 'curl'
# Clone repositories and install Doom Nvim
need_cmd 'git'
need_cmd 'git'
# Generate help tags
check_cmd 'ctags'
# Install LanguageServerProtocols
check_cmd 'npm'
check_cmd 'node'
check_cmd 'ctags'
# Install Language Server Protocols
check_cmd 'npm'
check_cmd 'node'
}
check_requirements() {
log_info "Checking requirements"
log_info "Checking requirements"
# Checks if git is installed again
if hash "git" &> /dev/null; then
git_version=$(git --version)
log_success "Check requirements : ${git_version}"
else
log_warn "Check requirements : git"
fi
# Checks if neovim is installed
if hash "nvim" &> /dev/null; then
log_success "Check requirements : nvim"
else
log_warn "Check requirements : nvim"
if hash "git" &>/dev/null; then
git_version=$(git --version)
log_success "Check requirements : ${git_version}"
else
log_warn "Check requirements : git"
fi
# Check if lua is installed again
if hash "lua" &> /dev/null; then
log_success "Check requirements : lua"
else
log_warn "Check requirements : lua"
fi
# Checks if neovim is installed
if hash "nvim" &>/dev/null; then
log_success "Check requirements : nvim"
else
log_warn "Check requirements : nvim"
fi
# Check if nodejs and npm are installed again,
# we do not check only nodejs because some Linux distributions
# installs nodejs but not also npm
if hash "node" &> /dev/null; then
if hash "node" &>/dev/null; then
log_success "Check requirements : node"
else
log_warn "Check requirements : node (optional, required to use LSP)"
fi
if hash "npm" &> /dev/null; then
if hash "npm" &>/dev/null; then
log_success "Check requirements : npm"
else
log_warn "Check requirements : npm (optional, required to use LSP)"
@ -137,51 +127,49 @@ check_requirements() {
}
# }}}
# Neovim backup and installation of Doom Nvim
# ===========================================
# {{{
backup_neovim() {
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.config\/doom-nvim$ ]]; then
log_success "Installed Doom Nvim and some demons were released, be careful!"
else
mv "$HOME/.config/nvim" "$HOME/.config/nvim_bak"
log_success "Neovim backup is in $HOME/.config/nvim_bak"
ln -s "$HOME/.config/doom-nvim" "$HOME/.config/nvim"
log_success "Installed Doom Nvim and more demons were released!"
fi
else
mkdir -p "$HOME/.config"
ln -s "$HOME/.config/doom-nvim" "$HOME/.config/nvim"
log_success "Installed Doom Nvim and now there are demons everywhere, be careful!"
fi
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.config\/doom-nvim$ ]]; then
log_success "Installed Doom Nvim and some demons were released, be careful!"
else
mv "$HOME/.config/nvim" "$HOME/.config/nvim_bak"
log_success "Neovim backup is in $HOME/.config/nvim_bak"
ln -s "$HOME/.config/doom-nvim" "$HOME/.config/nvim"
log_success "Installed Doom Nvim and more demons were released!"
fi
else
mkdir -p "$HOME/.config"
ln -s "$HOME/.config/doom-nvim" "$HOME/.config/nvim"
log_success "Installed Doom Nvim and now there are demons everywhere, be careful!"
fi
}
# }}}
# Doom Nvim updating
# ==================
# {{{
update_repo(){
if [[ -d "$HOME/.config/doom-nvim" ]]; then
log_info "Updating doom-nvim ..."
cd "$HOME/.config/doom-nvim"
git pull origin develop-nightly
cd - > /dev/null 2>&1
log_success "Successfully updated doom-nvim, more demons were released in your terminal!"
else
log_info "Trying to clone doom-nvim ..."
git clone -q -b develop-nightly https://github.com/NTBBloodbath/doom-nvim "$HOME/.config/doom-nvim"
if [ $? -eq 0 ]; then
log_success "Successfully cloned doom-nvim, some demons were released in your terminal!"
else
log_error "Failed to clone doom-nvim"
exit 0
fi
fi
update_repo() {
if [[ -d "$HOME/.config/doom-nvim" ]]; then
log_info "Updating doom-nvim ..."
cd "$HOME/.config/doom-nvim"
git pull # origin develop-nightly
cd - >/dev/null 2>&1
log_success "Successfully updated doom-nvim, more demons were released in your terminal!"
else
log_info "Trying to clone doom-nvim ..."
git clone -q -b "$1" https://github.com/NTBBloodbath/doom-nvim "$HOME/.config/doom-nvim"
if [ $? -eq 0 ]; then
log_success "Successfully cloned doom-nvim, some demons were released in your terminal!"
else
log_error "Failed to clone doom-nvim"
exit 0
fi
fi
}
install_nvim_nightly() {
@ -193,9 +181,9 @@ install_nvim_nightly() {
mv nvim.appimage $HOME/.local/bin/
if [ -f "$HOME/.zshrc" ]; then
echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >> $HOME/.zshrc
echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >>$HOME/.zshrc
else
echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >> $HOME/.bashrc
echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >>$HOME/.bashrc
fi
log_success "Successfully installed Neovim Nightly under $HOME/.local/bin/ directory"
@ -222,16 +210,16 @@ install_fonts() {
fi
cp $HOME/.local/share/fonts/* $HOME/Library/Fonts/
else
fc-cache -fv > /dev/null
mkfontdir "$HOME/.local/share/fonts" > /dev/null
mkfontscale "$HOME/.local/share/fonts" > /dev/null
fc-cache -fv >/dev/null
mkfontdir "$HOME/.local/share/fonts" >/dev/null
mkfontscale "$HOME/.local/share/fonts" >/dev/null
fi
log_success "Font cache done"
}
download_font() {
# Download patched Nerd Fonts
url="https://raw.githubusercontent.com/ryanoasis/nerd-fonts/patched-fonts/FiraCode/Regular/complete${1// /%20}"
url="https://github.com/ryanoasis/nerd-fonts/raw/2.1.0/patched-fonts/FiraCode/Regular/complete/${1// /%20}"
download_path="$HOME/.local/share/fonts/$1"
if [[ -f "$download_path" && ! -s "$download_path" ]]; then
rm "$download_path"
@ -241,24 +229,23 @@ download_font() {
log_success "Downloaded $1"
else
log_info "Downloading $1 ..."
curl -s -o "$download_path" "$url"
curl -sLo "$download_path" "$url"
log_success "Downloaded $1"
fi
}
install_done() {
echo ""
pretty_echo ${Green} "=================================================="
pretty_echo ${Green} " You are almost done. Start neovim to install "
pretty_echo ${Green} " the plugins and kill some demons. "
pretty_echo ${Green} " "
pretty_echo ${Green} " Thanks for installing Doom Nvim, if you have any "
pretty_echo ${Green} " issue, please report it :) "
pretty_echo ${Green} "=================================================="
echo ""
pretty_echo ${Green} "=================================================="
pretty_echo ${Green} " You are almost done. Start neovim to install "
pretty_echo ${Green} " the plugins and kill some demons. "
pretty_echo ${Green} " "
pretty_echo ${Green} " Thanks for installing Doom Nvim, if you have any "
pretty_echo ${Green} " issue, please report it :) "
pretty_echo ${Green} "=================================================="
}
# }}}
# Uninstall Doom Nvim
# ===================
# {{{
@ -274,119 +261,129 @@ uninstall() {
fi
fi
if [[ -d "$HOME/.config/doom-nvim" ]]; then
rm -rf "$HOME/.config/doom-nvim"
log_success "Completely uninstalled Doom Nvim and the demons have been disapeared"
if [[ -d "$HOME/.config/doom-nvim" ]]; then
rm -rf "$HOME/.config/doom-nvim"
log_success "Completely uninstalled Doom Nvim and the demons have been disapeared"
fi
}
# }}}
# Init banner
# ===========
# {{{
welcome() {
pretty_echo ${BRed} " ================= =============== =============== ======== ========"
pretty_echo ${BRed} " \\\\\ . . . . . . .\\\\\ //. . . . . . .\\\\\ //. . . . . . .\\\\\ \\\\\. . .\\\\\// . . //"
pretty_echo ${BRed} " ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||"
pretty_echo ${BRed} " || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||"
pretty_echo ${BRed} " ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||"
pretty_echo ${BRed} " || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||"
pretty_echo ${BYellow} " ||. . || ||-' || || \`-|| || . .|| ||. . || ||-' || || \`|\_ . .|. .||"
pretty_echo ${BYellow} " || . _|| || || || || ||_ . || || . _|| || || || |\ \`-_/| . ||"
pretty_echo ${BYellow} " ||_-' || .|/ || || \|. || \`-_|| ||_-' || .|/ || || | \ / |-_.||"
pretty_echo ${BYellow} " || ||_-' || || \`-_|| || || ||_-' || || | \ / | \`||"
pretty_echo ${BYellow} " || \`' || || \`' || || \`' || || | \ / | ||"
pretty_echo ${BYellow} " || .===' \`===. .==='.\`===. .===' /==. | \/ | ||"
pretty_echo ${BYellow} " || .==' \_|-_ \`===. .===' _|_ \`===. .===' _-|/ \`== \/ | ||"
pretty_echo ${BYellow} " || .==' _-' \`-_ \`=' _-' \`-_ \`=' _-' \`-_ /| \/ | ||"
pretty_echo ${BYellow} " || .==' _-' '-__\._-' '-_./__-' \`' |. /| | ||"
pretty_echo ${BYellow} " ||.==' _-' \`' | /==.||"
pretty_echo ${BRed} " ==' _-' \/ \`=="
pretty_echo ${BRed} " \ _-' N e o v i m \`-_ /"
pretty_echo ${BRed} " \`'' \`\`' "
pretty_echo ${BRed} " ================= =============== =============== ======== ========"
pretty_echo ${BRed} " \\\\\ . . . . . . .\\\\\ //. . . . . . .\\\\\ //. . . . . . .\\\\\ \\\\\. . .\\\\\// . . //"
pretty_echo ${BRed} " ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||"
pretty_echo ${BRed} " || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||"
pretty_echo ${BRed} " ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||"
pretty_echo ${BRed} " || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||"
pretty_echo ${BYellow} " ||. . || ||-' || || \`-|| || . .|| ||. . || ||-' || || \`|\_ . .|. .||"
pretty_echo ${BYellow} " || . _|| || || || || ||_ . || || . _|| || || || |\ \`-_/| . ||"
pretty_echo ${BYellow} " ||_-' || .|/ || || \|. || \`-_|| ||_-' || .|/ || || | \ / |-_.||"
pretty_echo ${BYellow} " || ||_-' || || \`-_|| || || ||_-' || || | \ / | \`||"
pretty_echo ${BYellow} " || \`' || || \`' || || \`' || || | \ / | ||"
pretty_echo ${BYellow} " || .===' \`===. .==='.\`===. .===' /==. | \/ | ||"
pretty_echo ${BYellow} " || .==' \_|-_ \`===. .===' _|_ \`===. .===' _-|/ \`== \/ | ||"
pretty_echo ${BYellow} " || .==' _-' \`-_ \`=' _-' \`-_ \`=' _-' \`-_ /| \/ | ||"
pretty_echo ${BYellow} " || .==' _-' '-__\._-' '-_./__-' \`' |. /| | ||"
pretty_echo ${BYellow} " ||.==' _-' \`' | /==.||"
pretty_echo ${BRed} " ==' _-' \/ \`=="
pretty_echo ${BRed} " \ _-' N e o v i m \`-_ /"
pretty_echo ${BRed} " \`'' \`\`' "
pretty_echo ${BYellow} " Version : ${DoomNvimVersion} By : NTBBloodbath "
echo ""
}
# }}}
# Helper and execution
# ====================
# {{{
helper() {
welcome
echo ""
pretty_echo ${BRed} " Usage ./install.sh [OPTION]"
echo ""
pretty_echo ${BRed} " OPTIONS:"
pretty_echo ${Yellow} " -h --help Displays this message"
pretty_echo ${Yellow} " -c --check-requirements Check Doom Nvim requirements"
pretty_echo ${Yellow} " -i --install Install Doom Nvim"
pretty_echo ${Yellow} " -n --nightly Install Neovim Nightly and Doom Nvim"
pretty_echo ${Yellow} " -u --update Update Doom Nvim"
pretty_echo ${Yellow} " -v --version Echo Doom Nvim version"
pretty_echo ${Yellow} " -x --uninstall Uninstall Doom Nvim"
pretty_echo ${BRed} " Usage ./install.sh [OPTION]"
echo ""
pretty_echo ${BRed} " OPTIONS:"
pretty_echo ${Yellow} " -h --help Displays this message"
pretty_echo ${Yellow} " -c --check-requirements Check Doom Nvim requirements"
pretty_echo ${Yellow} " -i --install Install Doom Nvim"
pretty_echo ${Yellow} " -d --install-dev Install Development version of Doom Nvim"
pretty_echo ${Yellow} " -n --nightly Install Neovim Nightly and Doom Nvim"
pretty_echo ${Yellow} " -u --update Update Doom Nvim"
pretty_echo ${Yellow} " -v --version Echo Doom Nvim version"
pretty_echo ${Yellow} " -x --uninstall Uninstall Doom Nvim"
}
main() {
if [ $# -gt 0 ]
then
if [ $# -gt 0 ]; then
case $1 in
--check-requirements|-c)
welcome
check_requirements
exit 0
;;
--update|-u)
welcome
update_repo
exit 0
;;
--install|-i)
welcome
check_all
update_repo
backup_neovim
install_done
exit 0
;;
--nvim-nightly|-n)
welcome
check_all
update_repo
backup_neovim
install_nvim_nightly
install_done
exit 0
;;
--help|-h)
helper
exit 0
;;
--version|-v)
log "Doom Nvim v${DoomNvimVersion}"
exit 0
;;
--uninstall|-x)
welcome
log_info "Uninstalling Doom Nvim ..."
uninstall
pretty_echo ${Green} "Thanks for using Doom Nvim, there are no more demons!"
exit 0
;;
esac
else
# Run normal commands
welcome
check_all
update_repo
backup_neovim
--check-requirements | -c)
welcome
check_requirements
exit 0
;;
--update | -u)
welcome
update_repo
exit 0
;;
--install | -i)
welcome
check_all
update_repo "main"
install_packer
install_fonts
backup_neovim
install_done
exit 0
;;
--install-dev | -d)
welcome
check_all
update_repo "develop-nightly"
install_packer
install_fonts
backup_neovim
install_done
exit 0
;;
--nvim-nightly | -n)
welcome
check_all
update_repo "main"
backup_neovim
install_nvim_nightly
install_done
exit 0
;;
--help | -h)
helper
exit 0
;;
--version | -v)
log "Doom Nvim v${DoomNvimVersion}"
exit 0
;;
--uninstall | -x)
welcome
log_info "Uninstalling Doom Nvim ..."
uninstall
pretty_echo ${Green} "Thanks for using Doom Nvim, there are no more demons!"
exit 0
;;
esac
else
# Run normal commands
welcome
check_all
update_repo "main"
backup_neovim
install_packer
install_fonts
check_requirements
install_done
fi
install_done
fi
}
main $@

Loading…
Cancel
Save