Browse Source

install bat, fix starship on arm

raylu 1 year ago
parent
commit
16ba856fe2
1 changed files with 21 additions and 1 deletions
  1. 21 1
      install_extras.py

+ 21 - 1
install_extras.py

@@ -13,6 +13,7 @@ import httpx
 CURRENT_DIR = pathlib.Path(__file__).parent
 
 def main():
+	bat()
 	delta()
 	dua()
 	eza()
@@ -20,6 +21,20 @@ def main():
 	lazygit()
 	starship()
 
+def bat():
+	if platform.system() == 'Darwin':
+		print('$ brew install git-delta')
+		subprocess.run(['brew', 'install', 'bat'], check=True)
+		return
+	else:
+		assert platform.system() == 'Linux'
+
+	if subprocess.run(['dpkg', '-l', 'bat'], stdout=subprocess.DEVNULL).returncode == 0:
+		print('bat package already installed')
+		return
+
+	subprocess.run(['sudo', 'apt', 'install', 'bat', '--yes'], check=True)
+
 def delta():
 	if platform.system() == 'Darwin':
 		print('$ brew install git-delta')
@@ -142,7 +157,12 @@ def starship():
 		return
 
 	client = httpx.Client()
-	url = f'https://github.com/starship/starship/releases/latest/download/starship-{platform.machine()}-unknown-linux-gnu.tar.gz'
+	arch = platform.machine()
+	if arch == 'x86_64':
+		libc = 'gnu'
+	else:
+		libc = 'musl'
+	url = f'https://github.com/starship/starship/releases/latest/download/starship-{arch}-unknown-linux-{libc}.tar.gz'
 	tarball_path = CURRENT_DIR / 'starship.tar.gz'
 	download(client, url, tarball_path)
 	with tarfile.open(tarball_path, 'r:gz') as tar: