Skip to content

Instantly share code, notes, and snippets.

@zero-pytagoras
Last active March 2, 2024 19:51
Show Gist options
  • Save zero-pytagoras/367aefdc105afc785508672e4aeacc26 to your computer and use it in GitHub Desktop.
Save zero-pytagoras/367aefdc105afc785508672e4aeacc26 to your computer and use it in GitHub Desktop.
vim_ide_setup.sh
#!/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