diff options
author | 2025-01-02 22:41:38 +0100 | |
---|---|---|
committer | 2025-01-02 22:41:38 +0100 | |
commit | e32d4d51496c6947739c2c38a7c14017915d43df (patch) | |
tree | 80d702ccd634cbb142a317f6949a719fe69c1d3f /install.zsh | |
download | zuwu-e32d4d51496c6947739c2c38a7c14017915d43df.tar.gz zuwu-e32d4d51496c6947739c2c38a7c14017915d43df.tar.bz2 zuwu-e32d4d51496c6947739c2c38a7c14017915d43df.tar.lz zuwu-e32d4d51496c6947739c2c38a7c14017915d43df.zip |
feat: initial commit
Diffstat (limited to 'install.zsh')
-rwxr-xr-x | install.zsh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/install.zsh b/install.zsh new file mode 100755 index 0000000..2c76cc4 --- /dev/null +++ b/install.zsh @@ -0,0 +1,46 @@ +#!/usr/bin/env zsh +set -eax +__filename="$(realpath "$0")" +__dirname="$(dirname "$__filename")" + +if [[ "$TARGET" != "" ]]; then + # no-op +elif [[ "$SYSROOT_PREFIX" != "" ]]; then + TARGET="$SYSROOT_PREFIX/usr/share/zsh/plugins/zuwu" +elif [[ "$PREFIX" != "" ]]; then + TARGET="$PREFIX/share/zsh/plugins/zuwu" +elif [[ "$(whoami)" == "root" ]]; then + TARGET="/usr/local/share/zsh/plugins/zuwu" +else + TARGET="$HOME/.local/share/zsh/plugins/zuwu" +fi +mkdir -p "$TARGET" + +if [[ "$(basename "$__filename")" == "zsh" ]]; then + echo 'todo: implement this' + exit 1 +else + cp -r "$__dirname/zuwu.zsh" "$TARGET/zuwu.zsh" +fi +<<EOF2 > "$TARGET/setup.zsh" +#!/usr/bin/env zsh +if [[ -f "\$HOME/.zshrc" ]]; then + local NEWZSHRC="\$HOME/.zshrc.\$(date -u +%Y-%m-%dT%H:%M:%S%Z)" + echo -e "\x1b[0;33mExitsing zshrc found, moving to \x1b[0;34m\$NEWZSHRC\x1b[0m" + mv "\$HOME/.zshrc" "\$NEWZSHRC" +fi +<<EOF > "\$HOME/.zshrc" +for d in /usr/share/zsh/plugins/zuwu /usr/local/share/zsh/plugins/zuwu \\\$HOME/.local/share/zsh/plugins/zuwu; do + if [[ -d "\\\$d" ]]; then + source "\\\$d/zuwu.zsh" + fi +done +EOF +echo -e "\x1b[0;32mPlease run \x1b[0;34msource \$HOME/.zshrc\x1b[0;32m to finish installing zuwu.\x1b[0m" +EOF2 +chmod +x "$TARGET/setup.zsh" +if [[ "$_ZUWU_INSTALLED" != "1" ]]; then + echo -e "\x1b[0;32mPlease run \x1b[0;34m$TARGET/setup.zsh\x1b[0;32m to install zuwu for the current user.\x1b[0m" +else + echo -e "\x1b[0;32mPlease run \x1b[0;34msource $HOME/.zshrc\x1b[0;32m to finish updating zuwu.\x1b[0m" +fi |