Last active
August 10, 2024 13:26
-
-
Save Eveeifyeve/ab9eedfacc1ba996a28b9de2694206ca to your computer and use it in GitHub Desktop.
reinstallAppsPyScrpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake | |
bun | |
gh | |
gradle | |
jenv | |
neovide | |
neovim | |
raycast | |
spicetify-cli | |
tmux | |
wezterm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from concurrent.futures import ThreadPoolExecutor | |
# Function to read apps from a text file | |
def read_apps_from_file(filename): | |
with open(filename, 'r') as file: | |
apps = [line.strip() for line in file] | |
return apps | |
# Read the list of applications from a text file | |
apps = read_apps_from_file('apps.txt') | |
def install_app(formula_name): | |
try: | |
subprocess.check_call(['brew', 'update']) | |
result = subprocess.run(['brew', 'install', formula_name], capture_output=True, text=True) | |
if "already installed" in result.stdout: | |
return True | |
else: | |
return True | |
except subprocess.CalledProcessError as e: | |
return False | |
def is_cask(formula_name): | |
try: | |
casks = subprocess.check_output(['brew', 'list', '--casks'], text=True).splitlines() | |
return formula_name in casks | |
except subprocess.CalledProcessError: | |
return False | |
def check_homebrew(): | |
subprocess.check_call(['brew', '--version']) | |
def main: | |
for formula_name in apps: | |
if install_app(formula_name): | |
# Skip casting if the app is a cask | |
if not is_cask(formula_name): | |
# print(f"\033[31mCasting is not supported for {formula_name}.\033[0m") | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment