3 # AX-ZSH: Alex' Modular ZSH Configuration
4 # Copyright (c) 2015 Alexander Barton <alex@barton.de>
7 # Include "ax-common.sh":
8 for dir in "$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr; do
9 [ -z "$ax_common_sourced" ] || break
10 ax_common="${dir}/lib/ax/ax-common.sh"
11 [ -r "$ax_common" ] && . "$ax_common"
13 if [ -z "$ax_common_sourced" ]; then
19 unset dir ax_common ax_common_sourced
22 if [ -f "$1" -a ! -L "$1" ]; then
23 rm -f "$1.bak" || abort
24 mv -v "$1" "$1.bak" || abort
30 ax_msg 2 "Failed to setup AX-ZSH!"
36 [ -n "$AXZSH" ] || AXZSH="$HOME/.axzsh"
41 if [ "$S" = "$AXZSH" -o "$PWD" = "$AXZSH" ]; then
42 ax_msg 1 "Initializing \"$AXZSH\":"
44 ax_msg 1 "Install AX-ZSH into \"$AXZSH\":"
46 [ -L "$AXZSH" ] && rm -f "$AXZSH"
47 mkdir -p "$AXZSH" || abort
49 ax_msg - "Copying binaries and scripts ..."
50 cp -pRv "$S/ax.zsh"* "$AXZSH/" || abort
51 mkdir -p "$AXZSH/bin" || abort
52 cp -pRv "$S/bin/"* "$AXZSH/bin/" || abort
54 for f in AUTHORS LICENSE.md README.md; do
55 cp -pRv "$S/$f" "$AXZSH/" || abort
58 ax_msg - "Copying plugins ..."
59 for plugin_type in core default_plugins plugins; do
60 mkdir -p "$AXZSH/$plugin_type" || abort
61 for p in "$S/$plugin_type/"*; do
62 echo "$p -> $AXZSH/$p"
63 rm -fr "${AXZSH:?}/$p" || abort
64 cp -pR "$S/$p" "$AXZSH/$p" || abort
69 mkdir -p "$AXZSH/custom_plugins" || abort
71 ax_msg - "Linking ZSH startup files ..."
73 for f in ~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc; do
75 ln -sv "$AXZSH/ax.zsh" "$f" || abort
78 if [ ! -d "$AXZSH/active_plugins" ]; then
79 ax_msg - "Initializing plugin directory \"$AXZSH/active_plugins\" ..."
80 which zsh >/dev/null 2>&1
82 zsh "$AXZSH/bin/axzshctl" reset-plugins || abort
84 ax_msg 1 "Oops, \"zsh\" not found!?"
87 ax_msg - "Plugin directory \"$AXZSH/active_plugins\" already exists. Ok."
90 ax_msg 0 "AX-ZSH setup successfully."