add option for sync or not sync profile

Variable MYSHELLCONFIG_GIT_SYNC in ~/.bashrc
if unset it defaults to true. So profile is synced
If Set to false, do not sync profile
This commit is contained in:
Jakobus Schürz 2020-02-25 16:15:32 +01:00
parent 8827e99d53
commit 42e20462ca

View file

@ -27,6 +27,7 @@ if [[ $- = *i* ]] ; then
[ -z "${MYSHELLCONFIG_GIT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_TIMEOUT=5s [ -z "${MYSHELLCONFIG_GIT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_TIMEOUT=5s
[ -z "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT=20s [ -z "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT+x}" ] && MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT=20s
MYSHELLCONFIG_BASH_COMPLETION="${HOME}/${MYSHELLCONFIG_SUBPATH}/bash_completion.d" MYSHELLCONFIG_BASH_COMPLETION="${HOME}/${MYSHELLCONFIG_SUBPATH}/bash_completion.d"
[ -z "${MYSHELLCONFIG_GIT_SYNC+x}" ] && MYSHELLCONFIG_GIT_SYNC=true
SGIT="git -C ${MYSHELLCONFIG_BASE}" SGIT="git -C ${MYSHELLCONFIG_BASE}"
export MYSHELLCONFIG_BASE MYSHELLCONFIG_LOGDIR MYSHELLCONFIG_LOGFILE SGIT MYSHELLCONFIG_VIM_PLUGINS export MYSHELLCONFIG_BASE MYSHELLCONFIG_LOGDIR MYSHELLCONFIG_LOGFILE SGIT MYSHELLCONFIG_VIM_PLUGINS
@ -47,22 +48,26 @@ EOF
} }
sync_config () { sync_config () {
local nok="" if $MYSHELLCONFIG_GIT_SYNC; then
local gco="" local nok=""
if which git >/dev/null; then local gco=""
echo -n "Sync config with ${MYSHELLCONFIG_GIT_SERVER}: " 1>&2 if which git >/dev/null; then
# MYSHELLCONFIG_GITCHECKOUTSCRIPT_OPTIONS are options for bin/git-myshellconfig-checkout echo -n "Sync config with ${MYSHELLCONFIG_GIT_SERVER}: " 1>&2
if [ -z ${MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS+x} ]; then # MYSHELLCONFIG_GITCHECKOUTSCRIPT_OPTIONS are options for bin/git-myshellconfig-checkout
gco="-h" if [ -z ${MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS+x} ]; then
else gco="-h"
gco="$MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS" else
fi gco="$MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS"
${MYSHELLCONFIG_BASE}/bin/git-myshellconfig-checkout ${gco}|| nok="not " 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 fi
printf '%s\n' "${nok}synced" 1>&2 ${MYSHELLCONFIG_BASE}/bin/git-myshellconfig-checkout ${gco}|| nok="not " 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1
[ -z "$nok" ] && mkdir -pv "${MYSHELLCONFIG_LOGDIR}" printf '%s\n' "${nok}synced" 1>&2
[ -z "$nok" ] && mkdir -pv "${MYSHELLCONFIG_LOGDIR}"
else
echo "git not installed, no configuration possible, please install git" >&2
fi
else else
echo "git not installed, no configuration possible, please install git" >&2 echo "Not syncing profile in case of configuration"
fi fi
} }