ax_common="${dir}/lib/ax/ax-common.sh"
[[ -r "$ax_common" ]] && source "$ax_common"
done
-if [[ -z "$ax_common_sourced" ]]; then
+if [[ -z "$ax_common_sourced" || axzsh_is_dumb_terminal ]]; then
function ax_msg {
shift
echo "$@"
echo
echo " upgrade"
echo " Upgrade AX-ZSH installation (requires Git)."
+ echo " update-caches"
+ echo " Force rebuild of all cache files."
echo
exit 2
}
-function DropCache {
- [[ -r "$AXZSH/cache" ]] \
- && echo "Dropping caches ..."
- rm -rf "$AXZSH/cache"
+function UpdatePluginCache {
+ [[ -r "$AXZSH/cache" ]] || return 0
+
+ ax_msg - "Updating plugin cache ..."
+ rm -rf \
+ $AXZSH/cache/zlogin.cache \
+ $AXZSH/cache/zlogout.cache \
+ $AXZSH/cache/zprofile.cache \
+ $AXZSH/cache/zshrc.cache \
+ || return 1
+ echo "Regenerating cache files ..."
+ zsh -ilc '' >/dev/null
}
function NormalizedPluginName {
ax_msg - "Cloning plugin from GitHub ..."
git clone "https://github.com/$1.git" \
"$AXZSH/repos/$plugin"
+ # Try to enable a theme in this "foreign" plugin, but
+ # ignore errors: we don't know if this plugin provides
+ # a theme at all ...
+ SetTheme "${plugin#*#}" 2>/dev/null
fi
fi
elif [ -r "$AXZSH/themes/$1.axzshtheme" ]; then
theme="$AXZSH/themes/$1.axzshtheme"
else
- echo "Theme \"$1\" not found!"
- return 1
+ # Look for theme inside of installed plugins:
+ for dname (
+ "$AXZSH/custom_plugins/"*(N)
+ "$AXZSH/repos/"*(N)
+ ); do
+ if [[ -r "$dname/$1.axzshtheme" ]]; then
+ theme="$dname/$1.axzshtheme"
+ break
+ elif [[ -r "$dname/$1.zsh-theme" ]]; then
+ theme="$dname/$1.zsh-theme"
+ break
+ fi
+ done
+ if [[ -z "$theme" ]]; then
+ echo "Theme \"$1\" not found!"
+ return 1
+ fi
fi
ln -sv "$theme" "$link_name" || return 1
return $?
for plugin in "$@"; do
EnablePlugin "$plugin"
done
- DropCache
+ UpdatePluginCache
;;
"disable-plugin")
[[ $# -gt 0 ]] || Usage
for plugin in "$@"; do
DisablePlugin "$plugin"
done
- DropCache
+ UpdatePluginCache
;;
"list-enabled")
[[ $# -eq 0 ]] || Usage
[[ $# -eq 0 ]] || Usage
ResetPlugins
EnableDefaultPlugins
- DropCache
+ UpdatePluginCache
;;
"enable-default-plugins")
[[ $# -eq 0 ]] || Usage
- EnableDefaultPlugins
- DropCache
+ EnableDefaultPlugins && UpdatePluginCache
;;
"check-plugins")
[[ $# -eq 0 ]] || Usage
;;
"set-theme")
[[ $# -eq 1 ]] || Usage
- SetTheme "$1"
- DropCache
+ SetTheme "$1" && UpdatePluginCache
;;
"upgrade")
[[ $# -eq 0 ]] || Usage
UpgradeAXZSH
UpgradeForeignPlugins
- DropCache
+ UpdatePluginCache
+ ;;
+ "update-caches")
+ [[ $# -eq 0 ]] || Usage
+ UpdatePluginCache
;;
*)
Usage