Browse Source

oh-my-posh

raylu 8 tháng trước cách đây
mục cha
commit
2e80e14119
2 tập tin đã thay đổi với 22 bổ sung2 xóa
  1. 1 0
      .gitignore
  2. 21 2
      install_extras.py

+ 1 - 0
.gitignore

@@ -5,4 +5,5 @@
 /eza
 /git-whence
 /lazygit
+/oh-my-posh
 /starship

+ 21 - 2
install_extras.py

@@ -20,6 +20,7 @@ def main():
 	eza()
 	git_whence()
 	lazygit()
+	oh_my_posh()
 	starship()
 
 def bat():
@@ -118,7 +119,6 @@ def dust():
 	os.unlink(tarball_path)
 	dust_path.chmod(0o755)
 
-
 def eza():
 	if platform.system() == 'Darwin':
 		print('$ brew install eza')
@@ -173,6 +173,26 @@ def lazygit():
 		tar.extract('lazygit', CURRENT_DIR)
 	os.unlink(CURRENT_DIR / 'lazygit.tgz')
 
+def oh_my_posh():
+	if platform.system() == 'Darwin':
+		print('$ brew install oh-my-posh')
+		subprocess.run(['brew', 'install', 'oh-my-posh'], check=True)
+		return
+	else:
+		assert platform.system() == 'Linux'
+
+	if (CURRENT_DIR / 'oh-my-posh').exists():
+		print('oh-my-posh already downloaded')
+		return
+
+	client = httpx.Client()
+	arch = platform.machine()
+	if arch == 'aarch64':
+		arch = 'arm64'
+	url = f'https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-{arch}'
+	download(client, url, CURRENT_DIR / 'oh-my-posh')
+	os.chmod(CURRENT_DIR / 'oh-my-posh', 0o755)
+
 def starship():
 	if platform.system() == 'Darwin':
 		print('$ brew install starship')
@@ -198,7 +218,6 @@ def starship():
 		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')