X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=bin%2Faxzshctl;h=b425679aecdf4513687a31f71fc1ac50afddcf4a;hb=f59153717abf80de1ceeca9687d4aff83b017559;hp=e399611ecc35d0995578e5788525fb53b5f12c85;hpb=4a29b74ab4c00bf960486f827255e595c406591a;p=ax-zsh.git diff --git a/bin/axzshctl b/bin/axzshctl index e399611..b425679 100755 --- a/bin/axzshctl +++ b/bin/axzshctl @@ -23,7 +23,7 @@ fi unset dir ax_common ax_common_sourced function Usage { - echo "$NAME [...]" + echo "Usage: $NAME [...]" echo echo " enable-plugin [ [...]]" echo " Enable plugin(s)." @@ -34,6 +34,15 @@ function Usage { echo " reset-plugins" echo " Reset active plugins to the default set." echo + echo " enable-default-plugins" + echo " Enable all default plugins." + echo + echo " set-theme |-" + echo " Set active theme to , or to the default." + echo + echo " upgrade" + echo " Upgrade AX-ZSH installation (requires Git)." + echo exit 2 } @@ -46,11 +55,13 @@ function EnablePlugin { fi for dname ( - "$AXZSH_PLUGIN_D/$plugin:A" - "$ZSH_CUSTOM/$plugin:A" - "$AXZSH/plugins/$plugin:A" - "$AXZSH/default_plugins/$plugin:A" - "$AXZSH/core/$plugin:A" + "$plugin:A" + "$AXZSH_PLUGIN_D/$plugin" + "$ZSH_CUSTOM/$plugin" + "$AXZSH/custom_plugins/$plugin" + "$AXZSH/plugins/$plugin" + "$AXZSH/default_plugins/$plugin" + "$AXZSH/core/$plugin" ); do [[ ! -d "$dname" ]] && continue mkdir -p "$dir" @@ -84,16 +95,64 @@ function ResetPlugins { ax_msg - "Removing all symbolic links in $dir ..." find "$dir" -type l -print -delete fi + return $? +} + +function EnableDefaultPlugins { + local dir="$AXZSH/active_plugins" ax_msg - "Activating (linking) default plugins ..." mkdir -p "$dir" ( cd "$dir" || exit 9 - ln -sv "$AXZSH/default_plugins/"* "$PWD" + ln -sfv "$AXZSH/default_plugins/"* "$PWD" ) return $? } +function SetTheme { + local link_name="$AXZSH/active_theme" + + if [ $# -ne 1 ]; then + echo "Usage: axzsh_set_theme " + return 1 + fi + + rm -f "$link_name" || return 1 + + if [ "$1" = "-" ]; then + echo "Theme settings have been reset." + return 0 + fi + + if [ -r "$1" ]; then + theme="$1" + elif [ -r "$AXZSH/custom_themes/$1.axzshtheme" ]; then + theme="$AXZSH/custom_themes/$1.axzshtheme" + elif [ -r "$AXZSH/themes/$1.axzshtheme" ]; then + theme="$AXZSH/themes/$1.axzshtheme" + else + echo "Theme \"$1\" not found!" + return 1 + fi + ln -sv "$theme" "$link_name" || return 1 + return $? +} + +function UpgradeAXZSH { + if [[ $+commands[git] -eq 0 ]]; then + ax_msg 2 "The git(1) command is not available!" + return 1 + fi + if [[ ! -d "$AXZSH/.git" ]]; then + ax_msg 2 "AX-ZSH seems not to be installed using Git. Can't upgrade!" + return 1 + fi + + ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..." + ( cd "$AXZSH" && git pull --ff-only ) +} + NAME="$(basename "$0")" [[ $# -gt 0 ]] || Usage @@ -122,6 +181,19 @@ case "$cmd" in "reset-plugins") [[ $# -eq 0 ]] || Usage ResetPlugins + EnableDefaultPlugins + ;; + "enable-default-plugins") + [[ $# -eq 0 ]] || Usage + EnableDefaultPlugins + ;; + "set-theme") + [[ $# -eq 1 ]] || Usage + SetTheme "$1" + ;; + "upgrade") + [[ $# -eq 0 ]] || Usage + UpgradeAXZSH ;; *) Usage