|
|
@@ -7,6 +7,7 @@ import platform
|
|
|
import shutil
|
|
|
import subprocess
|
|
|
import tarfile
|
|
|
+import zipfile
|
|
|
|
|
|
import httpx
|
|
|
|
|
|
@@ -24,6 +25,7 @@ def main():
|
|
|
lazygit()
|
|
|
oh_my_posh()
|
|
|
starship()
|
|
|
+ yazi()
|
|
|
|
|
|
def bat():
|
|
|
if platform.system() == 'Darwin':
|
|
|
@@ -265,6 +267,31 @@ def starship():
|
|
|
tar.extract('starship', CURRENT_DIR)
|
|
|
tarball_path.unlink()
|
|
|
|
|
|
+def yazi():
|
|
|
+ if platform.system() == 'Darwin':
|
|
|
+ print('$ brew install yazi')
|
|
|
+ subprocess.run(['brew', 'install', 'yazi'], check=True)
|
|
|
+ return
|
|
|
+ else:
|
|
|
+ assert platform.system() == 'Linux'
|
|
|
+
|
|
|
+ if (CURRENT_DIR / 'yazi').exists():
|
|
|
+ print_gray('yazi already downloaded')
|
|
|
+ return
|
|
|
+
|
|
|
+ client = httpx.Client()
|
|
|
+ name = f'yazi-{platform.machine()}-unknown-linux-musl'
|
|
|
+ url = f'https://github.com/sxyazi/yazi/releases/latest/download/{name}.zip'
|
|
|
+ zip_path = CURRENT_DIR / 'yazi.zip'
|
|
|
+ download(client, url, zip_path)
|
|
|
+ with zipfile.ZipFile(zip_path, 'r') as zipf:
|
|
|
+ for filename in ['ya', 'yazi']:
|
|
|
+ extracted = (CURRENT_DIR / filename)
|
|
|
+ with zipf.open(f'{name}/{filename}', 'r') as binary, extracted.open('wb') as f:
|
|
|
+ shutil.copyfileobj(binary, f)
|
|
|
+ extracted.chmod(0o755)
|
|
|
+ zip_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')
|