raylu 1 ano atrás
pai
commit
eaaedb022a
2 arquivos alterados com 27 adições e 3 exclusões
  1. 1 0
      .gitignore
  2. 26 3
      install_extras.py

+ 1 - 0
.gitignore

@@ -2,3 +2,4 @@
 /buildifier
 /eza
 /git-whence
+/starship

+ 26 - 3
install_extras.py

@@ -15,6 +15,7 @@ def main():
 	delta()
 	eza()
 	git_whence()
+	starship()
 
 def delta():
 	if platform.system() == 'Darwin':
@@ -58,10 +59,11 @@ def eza():
 
 	client = httpx.Client()
 	url = f'https://github.com/eza-community/eza/releases/latest/download/eza_{platform.machine()}-unknown-linux-gnu.tar.gz'
-	download(client, url, CURRENT_DIR / 'eza.tar.gz')
-	with tarfile.open(CURRENT_DIR / 'eza.tar.gz', 'r:gz') as tar:
+	tarball_path = CURRENT_DIR / 'eza.tar.gz'
+	download(client, url, tarball_path)
+	with tarfile.open(tarball_path) as tar:
 		tar.extract('./eza', CURRENT_DIR)
-	os.unlink(CURRENT_DIR / 'eza.tar.gz')
+	tarball_path.unlink()
 
 def git_whence():
 	if platform.system() == 'Darwin':
@@ -80,6 +82,27 @@ def git_whence():
 	download(client, url, CURRENT_DIR / 'git-whence')
 	os.chmod(CURRENT_DIR / 'git-whence', 0o755)
 
+def starship():
+	if platform.system() == 'Darwin':
+		print('$ brew install starship')
+		subprocess.run(['brew', 'install', 'starship'], check=True)
+		return
+	else:
+		assert platform.system() == 'Linux'
+
+	if (CURRENT_DIR / 'starship').exists():
+		print('starship already downloaded')
+		return
+
+	client = httpx.Client()
+	url = f'https://github.com/starship/starship/releases/latest/download/starship-{platform.machine()}-unknown-linux-gnu.tar.gz'
+	tarball_path = CURRENT_DIR / 'starship.tar.gz'
+	download(client, url, tarball_path)
+	with tarfile.open(tarball_path, 'r:gz') as tar:
+		tar.extract('starship', CURRENT_DIR)
+	tarball_path.unlink()
+
+
 def get_output(argv: list[str]) -> str:
 	proc = subprocess.run(argv, check=True, capture_output=True, encoding='ascii')
 	return proc.stdout.rstrip('\n')