1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

Use ASCII characters only

we want to be a universal Zsh framework, and send the message that
"less is less"!  ;- )

Don't indent done and failed messages with an indicator, at the end of
actions, to differentiate them from intermediate okay and error messages.
This commit is contained in:
Eric Nielsen 2019-12-13 07:14:10 -05:00
parent 4b750cb72f
commit 93bbc35634
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
13 changed files with 66 additions and 61 deletions

View file

@ -28,6 +28,6 @@ _zimfw_compile() {
done done
if [[ ${1} != -q ]]; then if [[ ${1} != -q ]]; then
print -P '%F{green}✓%f Done with compile.' print -P '<%= done %>Done with compile.'
fi fi
} }

View file

@ -3,7 +3,7 @@ _zimfw_build() {
local -r ztarget=${ZIM_HOME}/init.zsh local -r ztarget=${ZIM_HOME}/init.zsh
if [[ ${ztarget} -nt <%= home %>/.zimrc ]] && command cmp -s ${ztarget} ${1}; then if [[ ${ztarget} -nt <%= home %>/.zimrc ]] && command cmp -s ${ztarget} ${1}; then
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date" print -PR "<%= okay %>%B${ztarget}:%b Already up to date"
fi fi
else else
if [[ -e ${ztarget} ]]; then if [[ -e ${ztarget} ]]; then
@ -11,11 +11,11 @@ _zimfw_build() {
fi fi
command mv -f ${1} ${ztarget} && \ command mv -f ${1} ${ztarget} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f %B${ztarget}:%b Updated. Restart your terminal for changes to take effect." print -PR "<%= okay %>%B${ztarget}:%b Updated. Restart your terminal for changes to take effect."
fi fi
fi fi
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with build.' print -P '<%= done %>Done with build.'
fi fi
} =( } =(
print -R "zimfw() { source ${ZIM_HOME}/<%= script_filename %> \"\${@}\" }" print -R "zimfw() { source ${ZIM_HOME}/<%= script_filename %> \"\${@}\" }"

View file

@ -18,7 +18,7 @@ Startup options:
return 1 return 1
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red}${funcfiletrace[1]}: Missing zmodule url%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -40,7 +40,7 @@ Startup options:
shift shift
if [[ ${1} == (-n|--name) ]]; then if [[ ${1} == (-n|--name) ]]; then
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -53,7 +53,7 @@ Startup options:
case ${1} in case ${1} in
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source) -b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -89,7 +89,7 @@ Startup options:
;; ;;
-d|--disabled) zdisabled=1 ;; -d|--disabled) zdisabled=1 ;;
*) *)
print -u2 -PR "%F{red}${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
;; ;;
@ -105,7 +105,7 @@ Startup options:
_zdisableds+=(${zmodule}) _zdisableds+=(${zmodule})
else else
if [[ ! -d ${zdir} ]]; then if [[ ! -d ${zdir} ]]; then
print -u2 -PR "%F{red}${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi

View file

@ -2,7 +2,7 @@ _zimfw_source_zimrc() {
local -ri _zprepare_xargs=${1} local -ri _zprepare_xargs=${1}
local -i _zfailed=0 local -i _zfailed=0
if ! source <%= home %>/.zimrc || (( _zfailed )); then if ! source <%= home %>/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}✗ Failed to source <%= home %>/.zimrc%f" print -u2 -PR "%F{red}<%= failed %>Failed to source %B<%= home %>/.zimrc%b%f"
return 1 return 1
fi fi
} }

View file

@ -13,6 +13,6 @@ _zimfw_clean_compiled() {
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1 command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1
command rm -f ${zopt_rm} <%= home %>/.zshrc.zwc{,.old} || return 1 command rm -f ${zopt_rm} <%= home %>/.zshrc.zwc{,.old} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with clean-compiled. Run %Bzimfw compile%b to re-compile.' print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi fi
} }

View file

@ -4,6 +4,6 @@ _zimfw_clean_dumpfile() {
(( ! _zquiet )) && zopt='-v' (( ! _zquiet )) && zopt='-v'
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1 command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with clean-dumpfile. Restart your terminal to dump an updated configuration.' print -P '<%= done %>Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
fi fi
} }

View file

@ -9,6 +9,6 @@ _zimfw_uninstall() {
fi fi
done done
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with uninstall.' print -P '<%= done %>Done with uninstall.'
fi fi
} }

View file

@ -9,16 +9,16 @@ _zimfw_upgrade() {
fi fi
if command cmp -s ${zscript}{,.new}; then if command cmp -s ${zscript}{,.new}; then
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f %B<%= script_filename %>:%b Already up to date' print -P '<%= okay %>%B<%= script_filename %>:%b Already up to date'
fi fi
else else
command mv -f ${zscript}{,.old} && command mv -f ${zscript}{.new,} && \ command mv -f ${zscript}{,.old} && command mv -f ${zscript}{.new,} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f %B<%= script_filename %>:%b Upgraded. Restart your terminal for changes to take effect.' print -P '<%= okay %>%B<%= script_filename %>:%b Upgraded. Restart your terminal for changes to take effect.'
fi fi
fi fi
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with upgrade.' print -P '<%= done %>Done with upgrade.'
fi fi
} always { } always {
command rm -f ${zscript}.new command rm -f ${zscript}.new

View file

@ -58,7 +58,7 @@ Options:
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 || return 1
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect."
fi && \ fi && \
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
;; ;;

View file

@ -9,12 +9,12 @@ if [[ -e ${DIR} ]]; then
# Already exists # Already exists
return 0 return 0
fi fi
(( ! QUIET )) && print -Rn ${CLEAR_LINE}"Installing ${MODULE}" (( ! QUIET )) && print -Rn ${CLEAR_LINE}"Installing ${MODULE}<%= ellipsis %>"
if ERR=$(command git clone -b ${REV} -q --recursive ${URL} ${DIR} 2>&1); then if ERR=$(command git clone -b ${REV} -q --recursive ${URL} ${DIR} 2>&1); then
if (( ! QUIET )); then if (( ! QUIET )); then
print -PR ${CLEAR_LINE}"%F{green}✓%f %B${MODULE}:%b Installed" print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Installed"
fi fi
else else
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}}
return 1 return 1
fi fi

View file

@ -6,9 +6,9 @@ readonly TYPE=${4}
readonly REV=${5} readonly REV=${5}
readonly -i QUIET=${6} readonly -i QUIET=${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
(( ! QUIET )) && print -Rn ${CLEAR_LINE}"Updating ${MODULE}" (( ! QUIET )) && print -Rn ${CLEAR_LINE}"Updating ${MODULE}<%= ellipsis %>"
if ! builtin cd -q ${DIR} 2>/dev/null; then if ! builtin cd -q ${DIR} 2>/dev/null; then
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Not installed%f" print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Not installed%f"
return 1 return 1
fi fi
if [[ ${PWD} != $(command git rev-parse --show-toplevel 2>/dev/null) ]]; then if [[ ${PWD} != $(command git rev-parse --show-toplevel 2>/dev/null) ]]; then
@ -16,17 +16,17 @@ if [[ ${PWD} != $(command git rev-parse --show-toplevel 2>/dev/null) ]]; then
return 0 return 0
fi fi
if [[ ${URL} != $(command git config --get remote.origin.url) ]]; then if [[ ${URL} != $(command git config --get remote.origin.url) ]]; then
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b URL does not match. Expected ${URL}. Will not try to update.%f" print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b URL does not match. Expected ${URL}. Will not try to update.%f"
return 1 return 1
fi fi
if [[ ${TYPE} == tag ]]; then if [[ ${TYPE} == tag ]]; then
if [[ ${REV} == $(command git describe --tags --exact-match 2>/dev/null) ]]; then if [[ ${REV} == $(command git describe --tags --exact-match 2>/dev/null) ]]; then
(( ! QUIET )) && print -PR ${CLEAR_LINE}"%F{green}✓%f %B${MODULE}:%b Already up to date" (( ! QUIET )) && print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Already up to date"
return 0 return 0
fi fi
fi fi
if ! ERR=$(command git fetch -pq origin ${REV} 2>&1); then if ! ERR=$(command git fetch -pq origin ${REV} 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Error during git fetch%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git fetch%f"$'\n'${(F):- ${(f)^ERR}}
return 1 return 1
fi fi
if [[ ${TYPE} == branch ]]; then if [[ ${TYPE} == branch ]]; then
@ -36,12 +36,12 @@ else
fi fi
LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} 2>/dev/null) LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} 2>/dev/null)
if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Error during git checkout%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git checkout%f"$'\n'${(F):- ${(f)^ERR}}
return 1 return 1
fi fi
if [[ ${TYPE} == branch ]]; then if [[ ${TYPE} == branch ]]; then
if ! OUT=$(command git merge --ff-only --no-progress -n 2>&1); then if ! OUT=$(command git merge --ff-only --no-progress -n 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Error during git merge%f"$'\n'${(F):- ${(f)^OUT}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git merge%f"$'\n'${(F):- ${(f)^OUT}}
return 1 return 1
fi fi
# keep just first line of OUT # keep just first line of OUT
@ -52,9 +52,9 @@ fi
if ERR=$(command git submodule update --init --recursive -q 2>&1); then if ERR=$(command git submodule update --init --recursive -q 2>&1); then
if (( ! QUIET )); then if (( ! QUIET )); then
[[ -n ${LOG} ]] && OUT=${OUT}$'\n'${(F):- ${(f)^LOG}} [[ -n ${LOG} ]] && OUT=${OUT}$'\n'${(F):- ${(f)^LOG}}
print -PR ${CLEAR_LINE}"%F{green}✓%f %B${MODULE}:%b ${OUT}" print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${OUT}"
fi fi
else else
print -u2 -PR ${CLEAR_LINE}"%F{red}%B${MODULE}:%b Error during git submodule update%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git submodule update%f"$'\n'${(F):- ${(f)^ERR}}
return 1 return 1
fi fi

View file

@ -1,12 +1,17 @@
<%# coding: UTF-8 %><% <%
class Zim class Zim
attr_reader :home, :min_zsh_version, :script_filename, :second_stage_guard, :version attr_reader :home, :min_zsh_version, :script_filename, :version, :ellipsis, :okay, :error, :done, :failed
def initialize def initialize
@home = "${ZDOTDIR:-${HOME}}" @home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2" @min_zsh_version = "5.2"
@script_filename = "zimfw.zsh" @script_filename = "zimfw.zsh"
@version = "1.0.0-SNAPSHOT" @version = "1.0.0-SNAPSHOT"
@ellipsis = " ..."
@okay = "%F{green})%f "
@error = "x "
@done = ""
@failed = ""
end end
def render(filename) def render(filename)

View file

@ -62,7 +62,7 @@ _zimfw_compile() {
done done
if [[ ${1} != -q ]]; then if [[ ${1} != -q ]]; then
print -P '%F{green}✓%f Done with compile.' print -P 'Done with compile.'
fi fi
} }
@ -76,7 +76,7 @@ _zimfw_build() {
local -r ztarget=${ZIM_HOME}/init.zsh local -r ztarget=${ZIM_HOME}/init.zsh
if [[ ${ztarget} -nt ${ZDOTDIR:-${HOME}}/.zimrc ]] && command cmp -s ${ztarget} ${1}; then if [[ ${ztarget} -nt ${ZDOTDIR:-${HOME}}/.zimrc ]] && command cmp -s ${ztarget} ${1}; then
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}%f %B${ztarget}:%b Already up to date" print -PR "%F{green})%f %B${ztarget}:%b Already up to date"
fi fi
else else
if [[ -e ${ztarget} ]]; then if [[ -e ${ztarget} ]]; then
@ -84,11 +84,11 @@ _zimfw_build() {
fi fi
command mv -f ${1} ${ztarget} && \ command mv -f ${1} ${ztarget} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}%f %B${ztarget}:%b Updated. Restart your terminal for changes to take effect." print -PR "%F{green})%f %B${ztarget}:%b Updated. Restart your terminal for changes to take effect."
fi fi
fi fi
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with build.' print -P 'Done with build.'
fi fi
} =( } =(
print -R "zimfw() { source ${ZIM_HOME}/zimfw.zsh \"\${@}\" }" print -R "zimfw() { source ${ZIM_HOME}/zimfw.zsh \"\${@}\" }"
@ -118,7 +118,7 @@ Startup options:
return 1 return 1
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red} ${funcfiletrace[1]}: Missing zmodule url%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}: Missing zmodule url%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -140,7 +140,7 @@ Startup options:
shift shift
if [[ ${1} == (-n|--name) ]]; then if [[ ${1} == (-n|--name) ]]; then
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red} ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -153,7 +153,7 @@ Startup options:
case ${1} in case ${1} in
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source) -b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red} ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -189,7 +189,7 @@ Startup options:
;; ;;
-d|--disabled) zdisabled=1 ;; -d|--disabled) zdisabled=1 ;;
*) *)
print -u2 -PR "%F{red} ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"
_zfailed=1 _zfailed=1
return 1 return 1
;; ;;
@ -205,7 +205,7 @@ Startup options:
_zdisableds+=(${zmodule}) _zdisableds+=(${zmodule})
else else
if [[ ! -d ${zdir} ]]; then if [[ ! -d ${zdir} ]]; then
print -u2 -PR "%F{red} ${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -230,7 +230,7 @@ _zimfw_source_zimrc() {
local -ri _zprepare_xargs=${1} local -ri _zprepare_xargs=${1}
local -i _zfailed=0 local -i _zfailed=0
if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}Failed to source ${ZDOTDIR:-${HOME}}/.zimrc%f" print -u2 -PR "%F{red}Failed to source %B${ZDOTDIR:-${HOME}}/.zimrc%b%f"
return 1 return 1
fi fi
} }
@ -250,7 +250,7 @@ _zimfw_clean_compiled() {
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1 command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${zopt_find} || return 1
command rm -f ${zopt_rm} ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old} || return 1 command rm -f ${zopt_rm} ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with clean-compiled. Run %Bzimfw compile%b to re-compile.' print -P 'Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
fi fi
} }
@ -260,12 +260,12 @@ _zimfw_clean_dumpfile() {
(( ! _zquiet )) && zopt='-v' (( ! _zquiet )) && zopt='-v'
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1 command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with clean-dumpfile. Restart your terminal to dump an updated configuration.' print -P 'Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
fi fi
} }
_zimfw_info() { _zimfw_info() {
print 'Zim version: 1.0.0-SNAPSHOT (previous commit is 4a7ce44)' print 'Zim version: 1.0.0-SNAPSHOT (previous commit is f9dc5ea)'
print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)
@ -282,7 +282,7 @@ _zimfw_uninstall() {
fi fi
done done
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with uninstall.' print -P 'Done with uninstall.'
fi fi
} }
@ -297,16 +297,16 @@ _zimfw_upgrade() {
fi fi
if command cmp -s ${zscript}{,.new}; then if command cmp -s ${zscript}{,.new}; then
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}%f %Bzimfw.zsh:%b Already up to date' print -P '%F{green})%f %Bzimfw.zsh:%b Already up to date'
fi fi
else else
command mv -f ${zscript}{,.old} && command mv -f ${zscript}{.new,} && \ command mv -f ${zscript}{,.old} && command mv -f ${zscript}{.new,} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}%f %Bzimfw.zsh:%b Upgraded. Restart your terminal for changes to take effect.' print -P '%F{green})%f %Bzimfw.zsh:%b Upgraded. Restart your terminal for changes to take effect.'
fi fi
fi fi
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with upgrade.' print -P 'Done with upgrade.'
fi fi
} always { } always {
command rm -f ${zscript}.new command rm -f ${zscript}.new
@ -361,13 +361,13 @@ if [[ -e \${DIR} ]]; then
# Already exists # Already exists
return 0 return 0
fi fi
(( ! QUIET )) && print -Rn \${CLEAR_LINE}\"Installing \${MODULE} \" (( ! QUIET )) && print -Rn \${CLEAR_LINE}\"Installing \${MODULE} ...\"
if ERR=\$(command git clone -b \${REV} -q --recursive \${URL} \${DIR} 2>&1); then if ERR=\$(command git clone -b \${REV} -q --recursive \${URL} \${DIR} 2>&1); then
if (( ! QUIET )); then if (( ! QUIET )); then
print -PR \${CLEAR_LINE}\"%F{green}%f %B\${MODULE}:%b Installed\" print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b Installed\"
fi fi
else else
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Error during git clone%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git clone%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1 return 1
fi fi
" "
@ -381,9 +381,9 @@ readonly TYPE=\${4}
readonly REV=\${5} readonly REV=\${5}
readonly -i QUIET=\${6} readonly -i QUIET=\${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
(( ! QUIET )) && print -Rn \${CLEAR_LINE}\"Updating \${MODULE} \" (( ! QUIET )) && print -Rn \${CLEAR_LINE}\"Updating \${MODULE} ...\"
if ! builtin cd -q \${DIR} 2>/dev/null; then if ! builtin cd -q \${DIR} 2>/dev/null; then
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Not installed%f\" print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Not installed%f\"
return 1 return 1
fi fi
if [[ \${PWD} != \$(command git rev-parse --show-toplevel 2>/dev/null) ]]; then if [[ \${PWD} != \$(command git rev-parse --show-toplevel 2>/dev/null) ]]; then
@ -391,17 +391,17 @@ if [[ \${PWD} != \$(command git rev-parse --show-toplevel 2>/dev/null) ]]; then
return 0 return 0
fi fi
if [[ \${URL} != \$(command git config --get remote.origin.url) ]]; then if [[ \${URL} != \$(command git config --get remote.origin.url) ]]; then
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b URL does not match. Expected \${URL}. Will not try to update.%f\" print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b URL does not match. Expected \${URL}. Will not try to update.%f\"
return 1 return 1
fi fi
if [[ \${TYPE} == tag ]]; then if [[ \${TYPE} == tag ]]; then
if [[ \${REV} == \$(command git describe --tags --exact-match 2>/dev/null) ]]; then if [[ \${REV} == \$(command git describe --tags --exact-match 2>/dev/null) ]]; then
(( ! QUIET )) && print -PR \${CLEAR_LINE}\"%F{green}%f %B\${MODULE}:%b Already up to date\" (( ! QUIET )) && print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b Already up to date\"
return 0 return 0
fi fi
fi fi
if ! ERR=\$(command git fetch -pq origin \${REV} 2>&1); then if ! ERR=\$(command git fetch -pq origin \${REV} 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Error during git fetch%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git fetch%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1 return 1
fi fi
if [[ \${TYPE} == branch ]]; then if [[ \${TYPE} == branch ]]; then
@ -411,12 +411,12 @@ else
fi fi
LOG=\$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..\${LOG_REV} 2>/dev/null) LOG=\$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..\${LOG_REV} 2>/dev/null)
if ! ERR=\$(command git checkout -q \${REV} -- 2>&1); then if ! ERR=\$(command git checkout -q \${REV} -- 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Error during git checkout%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git checkout%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1 return 1
fi fi
if [[ \${TYPE} == branch ]]; then if [[ \${TYPE} == branch ]]; then
if ! OUT=\$(command git merge --ff-only --no-progress -n 2>&1); then if ! OUT=\$(command git merge --ff-only --no-progress -n 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Error during git merge%f\"$'\n'\${(F):- \${(f)^OUT}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git merge%f\"$'\n'\${(F):- \${(f)^OUT}}
return 1 return 1
fi fi
# keep just first line of OUT # keep just first line of OUT
@ -427,10 +427,10 @@ fi
if ERR=\$(command git submodule update --init --recursive -q 2>&1); then if ERR=\$(command git submodule update --init --recursive -q 2>&1); then
if (( ! QUIET )); then if (( ! QUIET )); then
[[ -n \${LOG} ]] && OUT=\${OUT}$'\n'\${(F):- \${(f)^LOG}} [[ -n \${LOG} ]] && OUT=\${OUT}$'\n'\${(F):- \${(f)^LOG}}
print -PR \${CLEAR_LINE}\"%F{green}%f %B\${MODULE}:%b \${OUT}\" print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${OUT}\"
fi fi
else else
print -u2 -PR \${CLEAR_LINE}\"%F{red} %B\${MODULE}:%b Error during git submodule update%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git submodule update%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1 return 1
fi fi
" "
@ -453,7 +453,7 @@ fi
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 || return 1
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." print -PR "Done with ${1}. Restart your terminal for any changes to take effect."
fi && \ fi && \
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
;; ;;