adjust dir structure

This commit is contained in:
2026-01-20 17:38:57 +08:00
parent e5d07895db
commit b387305048
6 changed files with 137 additions and 154 deletions

View File

@@ -13,28 +13,50 @@ else
fi
for i in "$@"; do
if [ "$i" = "install_ohmyzsh" ]; then
echo "Installing Oh My Zsh..."
zsh "$current_dir/install_ohmyzsh.sh"
if [ "$i" = "install" ]; then
echo "Installing related software..."
zsh "$current_dir/function/install.sh"
if [ $? -ne 0 ]; then
echo "Oh My Zsh installation failed."
echo "related software installation failed."
exit 1
fi
elif [ "$i" = "config_starship" ]; then
echo "Config Starship..."
zsh "$current_dir/config_starship.sh"
zsh "$current_dir/function/config_starship.sh"
if [ $? -ne 0 ]; then
echo "Starship configuration failed."
exit 1
fi
elif [ "$i" = "check" ]; then
echo "chcking uninstalled software..."
zsh "$current_dir/check.sh"
echo "Checking uninstalled software..."
zsh "$current_dir/function/check.sh"
if [ $? -ne 0 ]; then
echo "Check failed."
exit 1
fi
fi
done
# copying $HOME/.zshrc
current_dir=$(dirname $(realpath "$0"))
if [ -f "$HOME/.zshrc" ]; then
if $(file "$HOME/.zshrc" | grep -q "symbolic link") ; then
if [[ $(readlink "$HOME/.zshrc") != "$current_dir/zshrc" ]]; then
ln -sf "$current_dir/zshrc" "$HOME/.zshrc"
fi
else
if [ ! -f "$HOME/.zshrc.bkp" ]; then
mv "$HOME/.zshrc" "$HOME/.zshrc.bkp"
ln -s "$current_dir/zshrc" "$HOME/.zshrc"
else
echo "Backup file already exists. Please remove $HOME/.zshrc.bkp and try again."
exit 1
fi
fi
else
ln -s "$current_dir/zshrc" "$HOME/.zshrc"
fi
echo "Run \"exec zsh\" to apply changes."
# exec zsh