mingzailao-init/initialize.sh

67 lines
2.0 KiB
Bash
Raw Normal View History

2024-03-29 14:53:39 +08:00
#!/bin/bash
install_homebrew() {
# Check if Homebrew is already installed
if command -v brew &> /dev/null; then
echo "Homebrew is already installed."
else
# Check if the system is macOS (Darwin)
if [ "$(uname -s)" == "Darwin" ]; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
2024-03-29 15:03:00 +08:00
echo "This script is intended for macOS only. Continue..."
2024-03-29 14:53:39 +08:00
fi
fi
}
2024-03-29 14:58:58 +08:00
install_zsh() {
# Check if zsh is already installed
if command -v zsh &> /dev/null; then
echo "zsh is already installed."
else
# Check the operating system
if [ "$(uname)" == "Darwin" ]; then
# macOS specific installation
brew install zsh
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Linux specific installation
sudo apt-get install zsh # 适用于 Debian/Ubuntu 等
# 或者使用其他 Linux 发行版的安装命令
else
echo "Unsupported operating system. Cannot install zsh."
exit 1
fi
fi
# Set zsh as the default shell
if [ "$(uname)" == "Darwin" ]; then
2024-03-29 15:10:54 +08:00
chsh -s $(which zsh)
2024-03-29 14:58:58 +08:00
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
chsh -s $(which zsh)
else
echo "Unsupported operating system. Cannot set zsh as default shell."
exit 1
fi
echo "Zsh installation completed and set as the default shell. Please restart your terminal."
}
2024-03-21 07:11:07 +08:00
# install home-brew
2024-03-29 14:53:39 +08:00
install_homebrew
2024-03-21 07:11:07 +08:00
# install zsh
2024-03-29 14:58:58 +08:00
install_zsh
2024-03-21 07:11:07 +08:00
# install oh-my-zsh
2024-03-29 14:53:39 +08:00
#git clone https://git.mingzailao.live/mingzailao/ohmyzsh.git ~/.oh-my-zsh
#cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#chsh -s $(which zsh)
2024-03-21 07:11:07 +08:00
2024-03-26 18:07:04 +08:00
# install powerlevel10k
2024-03-29 14:53:39 +08:00
#git clone https://git.mingzailao.live/mingzailao/powerlevel10k.git ~/powerlevel10k
#echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc