Forráskód Böngészése

[+] Run MinTTY from cmd.exe

Hykilpikonna 2 éve
szülő
commit
7001d873b9
2 módosított fájl, 14 hozzáadás és 0 törlés
  1. 1 0
      hyfetch/main.py
  2. 13 0
      hyfetch/neofetch_util.py

+ 1 - 0
hyfetch/main.py

@@ -346,6 +346,7 @@ def run():
 
 
     # Ensure git bash for windows
     # Ensure git bash for windows
     ensure_git_bash()
     ensure_git_bash()
+    check_windows_cmd()
 
 
     # Test distro ascii art
     # Test distro ascii art
     if args.test_distro:
     if args.test_distro:

+ 13 - 0
hyfetch/neofetch_util.py

@@ -179,6 +179,19 @@ def ensure_git_bash() -> Path:
         print('Done!')
         print('Done!')
         return path / r'bin\bash.exe'
         return path / r'bin\bash.exe'
 
 
+
+def check_windows_cmd():
+    """
+    Check if this script is running under cmd.exe. If so, launch an external window with git bash
+    since cmd doesn't support RGB colors.
+    """
+    if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
+        print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
+        cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
+        os.system(cmd)
+        exit()
+
+
 def run_command(args: str, pipe: bool = False) -> str | None:
 def run_command(args: str, pipe: bool = False) -> str | None:
     """
     """
     Run neofetch command
     Run neofetch command