From 3a650ea31ae294c746b5e6497f907ca6fe23d695 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Sun, 10 Mar 2024 21:16:01 +0100 Subject: [PATCH] Improve sync --- profile.archlinux | 55 ++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/profile.archlinux b/profile.archlinux index 7de67f2..58d549a 100644 --- a/profile.archlinux +++ b/profile.archlinux @@ -1,6 +1,11 @@ # .profile for Archlinux based system from gardouille.home_public # https://git.101010.fr/gardouille-dotfiles/home_public +# Some colors {{{ +GREEN='\033[1;32m' +RED='\033[0;31m' +RESET='\033[0m' +# }}} # Manage dependencies {{{ ## Ensure to have git {{{ if [ ! $(command -v git) ]; then @@ -39,6 +44,12 @@ REPO_PATH="${HOME}/${REPO_DIR}" [ ! -d "${REPO_PATH}" ] && mkdir --parent -- "${REPO_PATH}" +# If .mrconfig.archlinux file is available {{{ +if [ -f "${HOME}"/.mrconfig.archlinux ]; then + ## Symlink it to .mrconfig + ln --symbolic "${REPO_DIR}"/.mrconfig.archlinux "${HOME}"/.mrconfig +fi +# }}} # If no .mrconfig file is available {{{ if [ ! -f "${HOME}"/.mrconfig ]; then ## Download a basic one @@ -54,22 +65,24 @@ if [ -f "${HOME}"/.git.update ]; then DATE_MTIME_GIT_FLAG=$(stat --format='%Y' "${HOME}"/.git.update) DATE_MAX=$(date --date="2 months ago" "+%s") - ### If the last update is too old + ### If the last update is too old {{{ + ### And GPG key is available if [ "${DATE_MTIME_GIT_FLAG}" -lt "${DATE_MAX}" ]; then ### Update all repositories with mr - mr update - - ### Update access time of git.update flag - touch "${HOME}"/.git.update + ### AND update access time of .git.update flag + nohup mr --quiet update \ + && touch "${HOME}"/.git.update & fi + ### }}} else - ### No .git.update flag file exists - - ### Update all repositories with mr - mr update - - ### Create a flag file to know the last update time - touch "${HOME}"/.git.update + ## Otherwise, just try to update if minimum configuration is available {{{ + if [ -e "${HOME}"/.mrconfig ]; then + ### Update all repositories with mr + ### AND create a .git.update flag + nohup mr --quiet update \ + && touch "${HOME}"/.git.update & + fi + ## }}} fi ## }}} @@ -106,27 +119,25 @@ if [ -f "${HOME}"/.vim/.plug.update ]; then ### If the last update is too old if [ "${DATE_MTIME_PLUG_FLAG}" -lt "${DATE_MAX_PLUG}" ]; then ### Update vim's plugins - vi +'PlugUpdate --sync' +qa - - ### Update access time of plug.update flag - touch "${HOME}"/.vim/.plug.update + ### AND update access time of .plug.update flag + vi -N -u "${HOME}"/.vimrc -c "PlugUpdate --sync" -c "qall" -U NONE -i NONE -e -s \ + && touch "${HOME}"/.vim/.plug.update & fi else ## Otherwise, just try to update/install if ~/.vim exists if [ -e "${HOME}"/.vim ]; then ### Download latest version of plug.vim - curl --no-progress-meter -fLo "${HOME}"/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + curl --no-progress-meter --fail --location --output "${HOME}"/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim ### Update/install vim's plugins - vi +'PlugUpdate --sync' +qa - - ### Create the flag file to know the last update time - touch "${HOME}"/.vim/.plug.update + ### AND create a .plug.update flag + vi -N -u "${HOME}"/.vimrc -c "PlugUpdate --sync" -c "qall" -U NONE -i NONE -e -s \ + && touch "${HOME}"/.vim/.plug.update & fi fi ## }}} # If ZSH is available and TERM var is set if [ $(command -v zsh) ] && [ "${TERM}" ]; then - exec zsh + exec zsh --login || echo "Error with ZSH" fi