Last active
March 2, 2024 19:51
-
-
Save zero-pytagoras/367aefdc105afc785508672e4aeacc26 to your computer and use it in GitHub Desktop.
vim_ide_setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
###############################################################3 | |
#Created by: Silent-Mobius AKA Alex M. Schapelle | |
#Purpose: automate vim ide setup | |
#Version: 0.1.9 | |
#Date: 23.02.2024 | |
set -x | |
set -o errexit | |
set -o pipefail | |
################################################################# | |
[[ -e /etc/os-release ]] && . /etc/os-release | |
CURL="$(which curl)" | |
DEPENDENCY_LIST=(vim vim-X11 curl) | |
INSTALLER="$([[ $ID == 'rocky' ]] && echo dnf || echo apt )" # flacky test | |
NULL=/dev/null | |
VIM_TEMPLATE="$($CURL -L https://gist.githubusercontent.com/zero-pytagoras/29b156158be7536534e17d4f8d2eef4a/raw/512f195521cee9280d334cb3e3698d9c1c5ac20b/vimrc)" | |
VIMRC="$HOME/.vimrc" | |
function main(){ | |
if [[ $EUID == "0" ]] || [[ $UID == "0" ]];then | |
echo "Do not use root user or sudo " | |
exit 1 | |
fi | |
dependency_check | |
vim_plug_install | |
vim_template_setup | |
vim_tool_install | |
} | |
function dependency_check(){ | |
for dependency in ${DEPENDENCY_LIST[@]} | |
do | |
if ! $INSTALLER list installed $dependency > $NULL 2>&1;then | |
sudo $INSTALLER install -y $dependency | |
fi | |
done | |
return 0 | |
} | |
function vim_plug_install(){ | |
if [[ ! -e ~/.vim/autoload/plug.vim ]];then | |
$CURL -fLo ~/.vim/autoload/plug.vim --create-dirs \ | |
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
fi | |
} | |
function vim_template_setup(){ | |
if [[ ${#VIM_TEMPLATE} -eq 0 ]];then | |
return 1 | |
else | |
if [[ -e $VIMRC ]];then | |
echo "$VIM_TEMPLATE" > $VIMRC | |
else | |
touch $VIMRC | |
echo "$VIM_TEMPLATE" > $VIMRC | |
fi | |
fi | |
} | |
function vim_tool_install(){ | |
vim +PlugInstall +all | |
} | |
###### | |
# Main - _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _- _ | |
###### | |
main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment