# Copyright (c) 2015-2020 Alexander Barton <alex@barton.de>
#
-# Include "ax-common.sh", if available:
-for dir ("$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr); do
- [[ -z "$ax_common_sourced" ]] || break
- ax_common="${dir}/lib/ax/ax-common.sh"
- [[ -r "$ax_common" ]] && source "$ax_common"
-done
-if [[ -z "$ax_common_sourced" ]]; then
- function ax_msg {
- shift
- echo "$@"
- }
- function ax_error {
- ax_msg 2 "$@" >&2
- }
-fi
-unset dir ax_common ax_common_sourced
+# Embedded ax-common compatibility functions ...
+function ax_msg {
+ case "$1" in
+ "0") c="32"; ;;
+ "1") c="33"; ;;
+ "2") c="31"; ;;
+ "-") c="1"; ;;
+ *) c="0"; ;;
+ esac
+ shift
+ printf "\e[${c}m%s\e[0m\n" "$@"
+}
+function ax_error {
+ ax_msg 2 "$@" >&2
+}
function Version {
echo "ax-zsh -- Modular configuration system for the Z shell (ZSH)"
plugin=${dir:t}
# Test if plugin is already enabled
- [[ -e "$AXZSH/active_plugins/$plugin" ]] \
- && enabled=" (enabled)" \
- || unset enabled
+ if [[ -e "$AXZSH/active_plugins/$plugin" ]]; then
+ printf ' \e[1;32m+\e[m "\e[1m%s\e[m" ... ' "${plugin}"
+ enabled=1
+ else
+ printf ' \e[1;31m-\e[m "%s" ... ' "${plugin}"
+ unset enabled
+ fi
# Test plugin ...
- printf " - \"%s\"%s ... " "$plugin" "$enabled"
new_plugin=""
for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do
[[ -r "$script" ]] || continue
ax_msg 1 "optional."
else
[[ -n "$enabled" ]] && invalid_plugins+=($plugin)
- ax_msg 2 "failed."
+ ax_msg 2 "failed ($r)."
fi
done
echo