Install Script Testing

This commit is contained in:
Dante 2024-03-13 11:42:02 -05:00 committed by GitHub
parent a523ee2b13
commit a11d325a19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1580 additions and 0 deletions

62
Scripts/restore_shl.sh Normal file
View file

@ -0,0 +1,62 @@
#!/bin/bash
#|---/ /+---------------------------+---/ /|#
#|--/ /-| Script to configure shell |--/ /-|#
#|-/ /--| Prasanth Rangan |-/ /--|#
#|/ /---+---------------------------+/ /---|#
source global_fn.sh
if [ $? -ne 0 ] ; then
echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..."
exit 1
fi
myShell="${1}"
if [ -z "${myShell}" ] ; then
if pkg_installed zsh ; then
myShell="zsh"
elif pkg_installed fish ; then
myShell="fish"
else
echo -e "\033[0;33m[WARNING]\033[0m no shell detected..."
exit 0
fi
fi
echo -e "\033[0;32m[SHELL]\033[0m detected // ${myShell}"
# add zsh plugins
if pkg_installed zsh && pkg_installed oh-my-zsh-git ; then
# set variables
Zsh_rc="${ZDOTDIR:-$HOME}/.zshrc"
Zsh_Path="/usr/share/oh-my-zsh"
Zsh_Plugins="$Zsh_Path/custom/plugins"
Fix_Completion=""
# generate plugins from list
while read r_plugin
do
z_plugin=$(echo $r_plugin | awk -F '/' '{print $NF}')
if [ "${r_plugin:0:4}" == "http" ] && [ ! -d $Zsh_Plugins/$z_plugin ] ; then
sudo git clone $r_plugin $Zsh_Plugins/$z_plugin
fi
if [ "$z_plugin" == "zsh-completions" ] && [ `grep 'fpath+=.*plugins/zsh-completions/src' $Zsh_rc | wc -l` -eq 0 ]; then
Fix_Completion='\nfpath+=${ZSH_CUSTOM:-${ZSH:-/usr/share/oh-my-zsh}/custom}/plugins/zsh-completions/src'
else
w_plugin=$(echo ${w_plugin} ${z_plugin})
fi
done < <(cut -d '#' -f 1 restore_zsh.lst | sed 's/ //g')
# update plugin array in zshrc
echo "intalling zsh plugins (${w_plugin})"
sed -i "/^plugins=/c\plugins=($w_plugin)$Fix_Completion" $Zsh_rc
fi
# set shell
if [[ "$(grep "/${USER}:" /etc/passwd | awk -F '/' '{print $NF}')" != "${myShell}" ]] ; then
echo -e "\033[0;32m[SHELL]\033[0m changing shell to ${myShell}..."
chsh -s "$(which ${myShell})"
else
echo -e "\033[0;33m[SKIP]\033[0m ${myShell} is already configured..."
fi