一键搭建开发环境

#!/bin/bash

# 检查是否安装了Xcode Command Line Tools
echo "Checking for Xcode Command Line Tools..."
if ! xcode-select -p &>/dev/null; then
    echo "Installing Xcode Command Line Tools..."
    xcode-select --install
else
    echo "Xcode Command Line Tools already installed."
fi

# 检查是否安装了Homebrew
echo "Checking for Homebrew..."
if ! command -v brew &>/dev/null; then
    echo "Installing Homebrew..."
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
else
    echo "Homebrew already installed."
fi

# 更新Homebrew
echo "Updating Homebrew..."
brew update

# 定义一个函数来检查应用是否已安装
install_if_not_installed() {
    app_name="$1"
    install_command="$2"

    if brew list --cask "$app_name" &>/dev/null || brew list "$app_name" &>/dev/null; then
        echo "$app_name is already installed."
    else
        echo "Installing $app_name..."
        eval "$install_command"
    fi
}

# 安装工具与应用
install_if_not_installed "cocoapods" "brew install cocoapods"
install_if_not_installed "developer" "brew install --cask developer"
install_if_not_installed "visual-studio-code" "brew install --cask visual-studio-code"
install_if_not_installed "wechat" "brew install --cask wechat"
install_if_not_installed "qq" "brew install --cask qq"
install_if_not_installed "youdaodict" "brew install --cask youdaodict"
install_if_not_installed "shadowsocksx-ng" "brew install --cask shadowsocksx-ng"
install_if_not_installed "v2rayx" "brew install --cask v2rayx"
install_if_not_installed "wps-office" "brew install --cask wps-office"
install_if_not_installed "baidunetdisk" "brew install --cask baidunetdisk"
install_if_not_installed "neteasemusic" "brew install --cask neteasemusic"

# 新增的应用
install_if_not_installed "cursor" "brew install --cask cursor"
install_if_not_installed "google-chrome" "brew install --cask google-chrome"
install_if_not_installed "sourcetree" "brew install --cask sourcetree"
install_if_not_installed "wechatwork" "brew install --cask wechatwork"
install_if_not_installed "feishu" "brew install --cask feishu"
install_if_not_installed "tencent-meeting" "brew install --cask tencent-meeting"
install_if_not_installed "charles" "brew install --cask charles"

# 清理Homebrew缓存
echo "Cleaning up..."
brew cleanup

echo "✅ All applications installed successfully!"
vi setup_dev_environment.sh
chmod +x setup_dev_environment.sh
./setup_dev_environment.sh
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容