Skip to content

Commit

Permalink
add script for installing brew apps
Browse files Browse the repository at this point in the history
  • Loading branch information
cning112 committed Jul 7, 2024
1 parent 69fa1f9 commit d482e39
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
raycast
warp
iterm2
nvim
keka
kap
keycastr
ffmpeg
imagemagick
wget
telnet
tldr

#slack
#discord
#figma
#vlc
#visual-studio-code
#sublime-text
53 changes: 53 additions & 0 deletions install_other_apps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# 确保 Homebrew 环境变量已设置
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is not installed or not configured properly. Please run the Homebrew installation script first."
exit 1
fi

# 函数:检查并安装应用程序
install_app() {
local app_name=$1

# 检查应用程序是否已安装
if brew list --formula | grep -Fxq "$app_name" || brew list --cask | grep -Fxq "$app_name"; then
echo "$app_name is already installed."
else
# 尝试通过 Homebrew 安装应用程序
if brew info --formula "$app_name" >/dev/null 2>&1; then
echo "Installing $app_name using brew..."
brew install "$app_name"
elif brew info --cask "$app_name" >/dev/null 2>&1; then
echo "Installing $app_name using brew cask..."
brew install --cask "$app_name"
else
echo "$app_name is not available via brew or brew cask."
fi
fi
}

# 主脚本逻辑
main() {
local file_path=$1

if [ -z "$file_path" ]; then
echo "Usage: $0 <path_to_apps.txt>"
exit 1
fi

if [ ! -f "$file_path" ]; then
echo "File $file_path not found."
exit 1
fi

while IFS= read -r app_name; do
# 跳过空行和以 # 开头的行
[[ -z "$app_name" || "$app_name" =~ ^# ]] && continue
install_app "$app_name"
done < "$file_path"
}

# 执行主脚本逻辑
main "$@"

0 comments on commit d482e39

Please sign in to comment.