Quidquid latine dictum sit, altum videtur

This commit is contained in:
Corrado Primier 2020-03-04 00:19:02 +00:00
parent 80bf80d416
commit 3f9ab2fffd

View File

@ -8,80 +8,78 @@ SCRIPTNAME=`basename "${SCRIPT}"`
SCRIPTDIR=`dirname "${SCRIPT}"`
REPODIR=`realpath ${SCRIPTDIR}/..`
msg() {
refere() {
echo "`tput bold`${*}`tput sgr0`"
}
info() {
echo "[`tput bold``tput setaf 2`INFO`tput sgr0`] `msg ${*}`"
indica() {
echo "[`tput bold``tput setaf 2`INFO`tput sgr0`] `refere ${*}`"
}
warn() {
echo "[`tput bold``tput setaf 3`WARN`tput sgr0`] `msg ${*}`"
admone() {
echo "[`tput bold``tput setaf 3`WARN`tput sgr0`] `refere ${*}`"
}
err() {
echo "[`tput bold``tput setaf 1`ERROR`tput sgr0`] `msg ${*}`"
erra() {
echo "[`tput bold``tput setaf 1`ERROR`tput sgr0`] `refere ${*}`"
}
install_file() {
persiste() {
src="${1}"
dst="${2}"
if [ ! -e "${dst}" ] ; then
mkdir -p "`dirname ${dst}`"
ln -s "${src}" "${dst}"
elif [ -d "${dst}" ] ; then
err "${dst} is a directory, expected a file, skipping"
elif [ -h "${dst}" ] && [ `realpath "${src}"` == `realpath "$dst"` ] ; then
info "`basename ${src}` already installed, skipping"
indica "=> `basename ${src}` already installed, skipping"
else
warn "${dst} is already present but it is not managed by `basename "${0}"`, skipping"
admone "=> ${dst} is already present but it is not managed by `basename "${0}"`, skipping"
fi
}
checkout_repo() {
inspice() {
url="${1}"
dst="${2}"
if [ ! -e "${dst}" ] ; then
mkdir -p "`realpath ${dst}/..`"
${git} clone "${url}" "$dst"
else
info "${dst} already present, skipping"
indica "${dst} already present, skipping"
fi
}
# basic
info "Initializing new submodules"
indica "Initializing new submodules"
"${git}" -C "${REPODIR}" submodule init
# scripts
info "Deploying scripts to ~/bin"
indica "Deploying scripts to ~/bin"
for script in `find "${SCRIPTDIR}" -mindepth 1 -maxdepth 1 -type f` ; do
scriptname="`basename "${script}"`"
install_file "${script}" "${HOME}/bin/${scriptname}"
persiste "${script}" "${HOME}/bin/${scriptname}"
done
unset scriptname
# bash
info "Deploying bash configuration"
install_file "${REPODIR}/.bashrc" "${HOME}"
indica "Deploying bash configuration"
persiste "${REPODIR}/.bashrc" "${HOME}/.bashrc"
# terminal colors
info "Configuring terminal colors"
checkout_repo https://github.com/chriskempson/base16-shell.git "${HOME}/.config/base16-shell"
indica "Configuring terminal colors"
inspice https://github.com/chriskempson/base16-shell.git "${HOME}/.config/base16-shell"
# tmux
info "Configuring tmux"
install_file "${REPODIR}/.tmux.conf" "${HOME}/.tmux.conf"
checkout_repo https://github.com/tmux-plugins/tpm "${HOME}/.tmux/plugins/tpm"
indica "Configuring tmux"
persiste "${REPODIR}/.tmux.conf" "${HOME}/.tmux.conf"
inspice https://github.com/tmux-plugins/tpm "${HOME}/.tmux/plugins/tpm"
# vim
info "Configuring vim"
ln -s "${REPODIR}/.vim/" "${HOME}/.vim/"
install_file "${REPODIR}/.vimrc" "${HOME}/.vimrc"
indica "Configuring vim"
persiste "${REPODIR}/.vim" "${HOME}/.vim"
persiste "${REPODIR}/.vimrc" "${HOME}/.vimrc"
# Update submodules
info "Updating all submodules"
indica "Updating all submodules"
"${git}" -C "${REPODIR}" submodule update --init --recursive --merge --remote
info "Done: verba volant, scripta manent"
indica "Factum est: verba volant, scripta manent"