Improve sync
This commit is contained in:
parent
5e84f4da5f
commit
3a650ea31a
|
@ -1,6 +1,11 @@
|
||||||
# .profile for Archlinux based system from gardouille.home_public
|
# .profile for Archlinux based system from gardouille.home_public
|
||||||
# https://git.101010.fr/gardouille-dotfiles/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 {{{
|
# Manage dependencies {{{
|
||||||
## Ensure to have git {{{
|
## Ensure to have git {{{
|
||||||
if [ ! $(command -v git) ]; then
|
if [ ! $(command -v git) ]; then
|
||||||
|
@ -39,6 +44,12 @@ REPO_PATH="${HOME}/${REPO_DIR}"
|
||||||
|
|
||||||
[ ! -d "${REPO_PATH}" ] && mkdir --parent -- "${REPO_PATH}"
|
[ ! -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 no .mrconfig file is available {{{
|
||||||
if [ ! -f "${HOME}"/.mrconfig ]; then
|
if [ ! -f "${HOME}"/.mrconfig ]; then
|
||||||
## Download a basic one
|
## 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_MTIME_GIT_FLAG=$(stat --format='%Y' "${HOME}"/.git.update)
|
||||||
DATE_MAX=$(date --date="2 months ago" "+%s")
|
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
|
if [ "${DATE_MTIME_GIT_FLAG}" -lt "${DATE_MAX}" ]; then
|
||||||
### Update all repositories with mr
|
### Update all repositories with mr
|
||||||
mr update
|
### AND update access time of .git.update flag
|
||||||
|
nohup mr --quiet update \
|
||||||
### Update access time of git.update flag
|
&& touch "${HOME}"/.git.update &
|
||||||
touch "${HOME}"/.git.update
|
|
||||||
fi
|
fi
|
||||||
|
### }}}
|
||||||
else
|
else
|
||||||
### No .git.update flag file exists
|
## Otherwise, just try to update if minimum configuration is available {{{
|
||||||
|
if [ -e "${HOME}"/.mrconfig ]; then
|
||||||
### Update all repositories with mr
|
### Update all repositories with mr
|
||||||
mr update
|
### AND create a .git.update flag
|
||||||
|
nohup mr --quiet update \
|
||||||
### Create a flag file to know the last update time
|
&& touch "${HOME}"/.git.update &
|
||||||
touch "${HOME}"/.git.update
|
fi
|
||||||
|
## }}}
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -106,27 +119,25 @@ if [ -f "${HOME}"/.vim/.plug.update ]; then
|
||||||
### If the last update is too old
|
### If the last update is too old
|
||||||
if [ "${DATE_MTIME_PLUG_FLAG}" -lt "${DATE_MAX_PLUG}" ]; then
|
if [ "${DATE_MTIME_PLUG_FLAG}" -lt "${DATE_MAX_PLUG}" ]; then
|
||||||
### Update vim's plugins
|
### Update vim's plugins
|
||||||
vi +'PlugUpdate --sync' +qa
|
### AND update access time of .plug.update flag
|
||||||
|
vi -N -u "${HOME}"/.vimrc -c "PlugUpdate --sync" -c "qall" -U NONE -i NONE -e -s \
|
||||||
### Update access time of plug.update flag
|
&& touch "${HOME}"/.vim/.plug.update &
|
||||||
touch "${HOME}"/.vim/.plug.update
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
## Otherwise, just try to update/install if ~/.vim exists
|
## Otherwise, just try to update/install if ~/.vim exists
|
||||||
if [ -e "${HOME}"/.vim ]; then
|
if [ -e "${HOME}"/.vim ]; then
|
||||||
### Download latest version of plug.vim
|
### 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
|
### Update/install vim's plugins
|
||||||
vi +'PlugUpdate --sync' +qa
|
### AND create a .plug.update flag
|
||||||
|
vi -N -u "${HOME}"/.vimrc -c "PlugUpdate --sync" -c "qall" -U NONE -i NONE -e -s \
|
||||||
### Create the flag file to know the last update time
|
&& touch "${HOME}"/.vim/.plug.update &
|
||||||
touch "${HOME}"/.vim/.plug.update
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
# If ZSH is available and TERM var is set
|
# If ZSH is available and TERM var is set
|
||||||
if [ $(command -v zsh) ] && [ "${TERM}" ]; then
|
if [ $(command -v zsh) ] && [ "${TERM}" ]; then
|
||||||
exec zsh
|
exec zsh --login || echo "Error with ZSH"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue