aboutsummaryrefslogtreecommitdiffstats
path: root/install.zsh
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-22 16:35:29 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-22 16:35:29 +0100
commit364494371016d140478d45b7c57c926b82e3c610 (patch)
tree1bf18c2e175c26ad6b709287f53e0257535e5510 /install.zsh
parent9300c0e8c19352da49c99b07b3d8086d1403e331 (diff)
downloadzuwu-364494371016d140478d45b7c57c926b82e3c610.tar.gz
zuwu-364494371016d140478d45b7c57c926b82e3c610.tar.bz2
zuwu-364494371016d140478d45b7c57c926b82e3c610.tar.lz
zuwu-364494371016d140478d45b7c57c926b82e3c610.zip

feat(installer): make zuwu installer suggest running the install cmd after removal of shellrc

additional changes:

  • fix(installer): if ZSH_NAME is unset, complain
  • fix(installer): if _ZUWU_DETECTED_INSTALL_PATH is set, overwrite it with the installer path
Diffstat (limited to 'install.zsh')
-rwxr-xr-xinstall.zsh12
1 files changed, 11 insertions, 1 deletions
diff --git a/install.zsh b/install.zsh
index 933150c..223089b 100755
--- a/install.zsh
+++ b/install.zsh
@@ -1,5 +1,11 @@
#!/usr/bin/env zsh
set -e
+
+if [[ "$ZSH_NAME" == "" ]]; then
+ echo -e "\x1b[0;31mThe installer expects ZSH to be the executing shell, lmao.\x1b[0m"
+ exit 1
+fi
+
__filename="$(realpath "$0")"
__dirname="$(dirname "$__filename")"
@@ -39,6 +45,10 @@ fi
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"
+ # For debugging, calling _ZUWU_DETECTED_INSTALL_PATH=/dev/null zsh -c 'source ~/.zshrc && echo "\\\$_ZUWU_DETECTED_INSTALL_PATH"' may be useful
+ if [[ "\\\$_ZUWU_DETECTED_INSTALL_PATH" != "" ]]; then
+ _ZUWU_DETECTED_INSTALL_PATH="\\\$d"
+ fi
break
fi
done
@@ -46,7 +56,7 @@ EOF_ZSHRC
echo -e "\x1b[0;32mPlease run \x1b[0;34msource \$HOME/.zshrc\x1b[0;32m to load zuwu into the current shell.\x1b[0m"
EOF_SETUPSCRIPT
chmod +x "$TARGET/setup.zsh"
-if [[ "$_ZUWU_INSTALLED" != "1" ]]; then
+if [[ "$_ZUWU_INSTALLED" != "1" ]] || ! [[ -f "$HOME/.zshrc" ]]; 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"