This commit is contained in:
Atomic Coding 2018-04-17 02:47:06 +00:00 committed by GitHub
commit d462ac3151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 102 additions and 0 deletions

View File

@ -46,3 +46,11 @@ Aliases `get` to ( `aria2c` || `axel` || `wget` || `curl` ).
| alias | description |
| ----- | ----------- |
| `mkcd` | `mkdir -p` and `cd` |
Commands
--------
| command | description |
| ----- | ----------- |
| `module_update` | `Updates git-installed modules and themes specified in the zimrc` |

View File

@ -0,0 +1,85 @@
local currentdir=$(pwd)
local updated=0
local failed=0
local module
local mlocation
local nfailed
local ncolors red green yelllow blue bold normal
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "${ncolors}" ] && [ "${ncolors}" -ge 8 ]; then
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
bold="$(tput bold)"
normal="$(tput sgr0)"
else
red=""
green=""
yellow=""
blue=""
bold=""
normal=""
fi
for module in $umodules; do
nfailed=0
if [ -d ${ZIM_HOME}/modules/${module} ]; then
mlocation=${ZIM_HOME}/modules/${module}
elif [ -d ${ZIM_HOME}/modules/prompt/external-themes/${module} ]; then
mlocation=${ZIM_HOME}/modules/prompt/external-themes/${module}
else
echo "${red}Cant find $module module...$normal"
break
fi
echo -ne "${blue}Updating $module... $normal"\\r
output=$(cd $mlocation && git remote update -p && git merge --ff-only @\{u\})
if [ $? -ne 0 ]; then
echo -ne "${red}Failed to update $module...\n $output $normal"\\r
failed=$((failed+1))
nfailed=1
fi
if ! [ ${nfailed} = "1" ]; then
if echo "$output" | grep -i "up to date" > /dev/null; then
echo -ne "${blue}$module at latest version. $normal"\\r
else
echo -ne "${green}Updated $module! $normal"\\r
updated=$((updated+1))
fi
fi
printf '\n'
done
for pmodule in $pmodules; do
echo -ne "${blue}Updating $pmodule... $normal"\\r
output=$(cd ${ZIM_HOME}/modules/prompt/external-themes/$pmodule && git remote update -p && git merge --ff-only @\{u\})
if [ $? -ne 0 ]; then
echo -ne "${red}Failed to update $pmodule...\n $output $normal"\\r
failed=$((failed+1))
fi
if echo "$output" | grep -i "up to date" > /dev/null; then
echo -ne "${blue}$pmodule at latest version. $normal"\\r
else
echo -ne "${green}Updated $pmodule! $normal"\\r
updated=$((updated+1))
fi
printf '\n'
done
if [ $updated -gt 0 ]; then
if [ $failed -eq 0 ]; then
echo "${green}${bold}Sucessfully updated $updated modules!$normal"
fi
else
if [ $failed -eq 0 ]; then
echo "${blue}${bold}No module updates avaliable.$normal"
fi
fi
if [ $failed -gt 0 ]; then
if [ $updated -gt 0 ]; then
echo "${blue}${bold}Sucessfully updated $updated modules and failed to update $failed modules.$normal"
else
echo "${red}${bold}Failed to update $failed modules, no module updates available.$normal"
fi
fi
cd $currentdir

View File

@ -53,6 +53,15 @@ zprompt_theme='steeef'
# The example below uses the following format: 'username@host:/current/directory'
ztermtitle='%n@%m:%~'
#
# Updater
#
# Set modules or themes to update (they must be a valid git repo)
#umodules=()
#
# Input
#